pub fn parse_uri(uri: &str) -> Result<Uri>Expand description
Converts a human-facing URL string into the internal http::Uri
representation.
NOTE: the name is misleading. For http/https this is an ordinary parse,
but for the file/unix/windows schemes it encodes the path into the
URI authority (see encode_uri_path_in_authority), so it is a
URL-string-to-Uri constructor, not a pure parser.
WARNING: this is NOT idempotent for those three schemes. The Uri it
returns stringifies back to the encoded form (file://<hex>/), and feeding
that string in again re-encodes it, double-encoding the path. Only ever call
this on an original URL string — never on the .to_string() of a Uri that
already came out of here.
TODO: we should properly handle malformed urls
- For windows and unix schemes:
- For compatibility reasons with existing implementation this parser stores the encoded path in authority section as there is no existing standard see that covers this. We need to pick one hack or another
- For windows, interprets everything after windows: as path
- For unix, interprets everything after unix:// as path
- For file scheme implementation will simply backfill missing authority section