servo / rust-url

URL parser for Rust
https://docs.rs/url/
Apache License 2.0
1.32k stars 330 forks source link

enhancement request: path_raw() #602

Open dan-da opened 4 years ago

dan-da commented 4 years ago

Sometimes one just wants to parse the raw url components and display/log/process them exactly as entered, without any normalization.

At present, I am in need of the exact string in the path, including "../" without any normalization. I can perform the percent-decoding if necessary.

If I've overlooked an existing way to do this, please advise.

dan-da commented 4 years ago

I posted a more complete example here: https://stackoverflow.com/questions/62335488/how-to-obtain-raw-url-path-in-rust

dan-da commented 3 years ago

wow, it's been over a year and our code still has an ugly workaround. any comment about this?

tmccombs commented 3 years ago

I think that the original path is lost during parsing. I think that this would have to be an option during parsing, not a method on Url

dan-da commented 3 years ago

maybe there could be a parse option to not throw it away...

anyway, I'm not stuck on the exact impl, so long as its possible to obtain somehow. Seems like presently ::parse() is more of parse+transform rather than just parsing. I think one should be able to get at each of the raw parsed components (scheme, user, pass, host, port, path, query-string, fragment), before they go through transformations (decoding, path normalization, etc). maybe add a parse_raw() fn.