question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Extra slashes causes route error

See original GitHub issue

Extra slashes in the URL change the routing. For example, /x and //x do not route the same way. Here’s a unit test which demonstrates this:

https://gist.github.com/robnagler/1a5d0361cc71a6806fc6

If you put a proxy in front of flask, it will normalize the URLs so this isn’t an issue. It would seem, however, that Flask should normalize the URLs as well.

Issue Analytics

  • State:closed
  • Created 9 years ago
  • Comments:14 (10 by maintainers)

github_iconTop GitHub Comments

3reactions
robnaglercommented, Jan 20, 2015

On most operating systems, extra slashes resolve to one. URLs came from file system notation so it would seem that the two should respond in the same way.

Apache removes duplicate slashes for a good reason.

Nginx has the merge_slashes directive, which is on by default.

RFC 3986 seems to imply you can’t have multiple, contiguous slashes:

      path          = path-abempty    ; begins with "/" or is empty
                    / path-absolute   ; begins with "/" but not "//"
                    / path-noscheme   ; begins with a non-colon segment
                    / path-rootless   ; begins with a segment
                    / path-empty      ; zero characters

      path-abempty  = *( "/" segment )
      path-absolute = "/" [ segment-nz *( "/" segment ) ]
      path-noscheme = segment-nz-nc *( "/" segment )
      path-rootless = segment-nz *( "/" segment )
      path-empty    = 0<pchar>
      segment       = *pchar
      segment-nz    = 1*pchar
      segment-nz-nc = 1*( unreserved / pct-encoded / sub-delims / "@" )
                    ; non-zero-length segment without any colon ":"

      pchar         = unreserved / pct-encoded / sub-delims / ":" / "@"

Note that path-* require segment-nz. segment-nz requires at least one pchar, which cannot be a slash.

0reactions
davidismcommented, Jun 5, 2017

This is a Werkzeug issue, reported at pallets/werkzeug#1132.

Read more comments on GitHub >

github_iconTop Results From Across the Web

What causes double slashes in url path?
Double slashes are usually caused by redirect rules. ... The problem is compounded by relative links once a crawler finds a URL with...
Read more >
url with multiple forward slashes, does it break anything?
I have a script that parses URLs and i was wondering if it would break anything (or change the path) if i replaced...
Read more >
"Double slash in URL" error in Site Audit | Help Center - Ahrefs
This issue reports all URLs that contain a double slash (after the domain part). Example: https://ahrefs.com/blog//. Why is it important? Most servers are ......
Read more >
URL contains a double slash | Sitebulb
A double slash in the URL path is valid and will respond in the browser, but is typically unwelcome, as this could cause...
Read more >
Why is a double slash valid in a file path? - Progress Community
A file path containing, two consecutive slashes, does not cause any kind of a run-time error. Why is this valid?
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found