Closed reem closed 9 years ago
We encode trailing slashes with a ""
in the path, so you could do:
if url.path.last().unwrap() == "" {
url.path.pop();
}
@michaelsproul What are /
and nothing encoded as?
(I'm getting an infinite redirect on localhost:3000/
and localhost:3000
when detecting trailing urls with .last() == Some("".to_owned())
and then pop
ing to get a trailing-slash-less url)
Hmm, I think we actually encode localhost:3000
as localhost:3000/
, i.e. with a path of [""]
... The docs say the path is always non-empty, and I vaguely remember this being passed along from the rust-url
library.
I'll just add a check for path.len() != 1
to handle the final case.
@michaelsproul what's the best way to get a Url without the trailing slash from a Url with a trailing slash?