Skip to content

Commit

Permalink
Merge into servestatic
Browse files Browse the repository at this point in the history
  • Loading branch information
Archmonger committed Aug 27, 2024
1 parent dc73e83 commit e1d2b07
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 209 deletions.
8 changes: 6 additions & 2 deletions src/servestatic/middleware.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@
import concurrent.futures
import contextlib
import os
from posixpath import basename
from posixpath import basename, normpath
from typing import AsyncIterable
from urllib.parse import urlparse
from urllib.request import url2pathname

import django
from aiofiles.base import AiofilesContextManager
Expand Down Expand Up @@ -252,7 +253,10 @@ def add_files_from_finders(self):

def candidate_paths_for_url(self, url):
if self.use_finders and url.startswith(self.static_prefix):
path = finders.find(url[len(self.static_prefix) :])
relative_url = url[len(self.static_prefix) :]
path = url2pathname(relative_url)
normalized_path = normpath(path).lstrip("/")
path = finders.find(normalized_path)
if path:
yield path
paths = super().candidate_paths_for_url(url)
Expand Down
207 changes: 0 additions & 207 deletions src/whitenoise/middleware.py

This file was deleted.

0 comments on commit e1d2b07

Please sign in to comment.