Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ Using the following categories, list your changes in this order:

### Fixed

- Fix Django "StreamingHttpResponse must consume synchronous iterators" warning
- Fix Django `StreamingHttpResponse must consume synchronous iterators` warning
- Fix Django bug where file paths could fail to be followed on Windows ([Upstream PR](https://github.com/evansd/whitenoise/pull/474))

## [1.0.0] - 2024-05-08

Expand Down
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