pub fn normalize_path(path: &str) -> Cow<'_, str>Expand description
The path of a request in the form it is matched by: percent-encoding
decoded, path parameters left out, a backslash taken for a slash, .
and .. segments resolved, repeated slashes merged.
Which location a request belongs to is decided on this form, because it
is the form most upstreams go on to serve. Matching the path as it was
sent let /%61dmin, //admin and /public/../admin slip past a
location for /admin, and whatever plugins guard it, on their way to
an upstream that reads all three as /admin. Only the matching uses
it; the request is forwarded as it came.
Two of these are what some upstreams read and others do not. A servlet
container drops the ;name=value of a segment before it looks at the
path, so to Tomcat /public/..;/admin and /api;v=1/admin are
/admin and /api/admin; IIS takes \ for /. An upstream that does
neither has nothing at such a path, so reading it the way the others do
costs it nothing, and the ones that do are no longer reached past the
location that was meant to stand in front of them.
A path with nothing to change, which is nearly every path, is returned as it is.