Conversation
for more information, see https://pre-commit.ci
codingjoe
left a comment
There was a problem hiding this comment.
Hi there 👋,
I had some time and was browsing for reviews. I hope you don't mind me leaving some notes.
Cheerio!
Joe
|
@codingjoe I’ll update the implementation to simplify the slash normalization (likely using regex as you suggested) and reduce branching in the middleware. I’ll also explore the try/except approach so the normalization only happens when a 404 occurs, keeping the common path fast. Additionally, I’ll add a few adverse test cases to better cover edge scenarios. Thanks again for the feedback — I’ll push an update shortly. |
|
I have updated the middleware to normalize multiple slashes in the URL using a regex . I also added a test case in test_www_urls.py to ensure that URLs like /community// correctly redirect to /community/ with a 301 status. Please let me know if any further changes are needed. Thanks again for the guidance! |
Fixes #2067
This PR adds middleware to normalize URLs containing extra slashes
(e.g.
//community//→/community/) so links and assets resolve correctly.Includes tests to ensure correct redirects on www.djangoproject.com.