Skip to main content

Crate url_parse_nginx

Crate url_parse_nginx 

Source
Expand description

Parse and normalize URL paths using nginx semantics.

parse_path_and_query accepts an origin-form request target, normalizes its path, and returns the query string separately. Path normalization percent-decodes %XX, resolves . and .. segments, and optionally merges adjacent slashes.

Only origin-form request targets starting with / are supported. The parsing behavior follows nginx on Linux; Windows-specific nginx behavior is not supported.

§Example

use url_parse_nginx::parse_path_and_query;

let parsed = parse_path_and_query(b"/docs/../hello%20world?x=1", true)?;
assert_eq!(&*parsed.path, b"/hello world"); // ".." resolved, "%20" decoded
assert_eq!(parsed.args, Some(&b"x=1"[..]));

Structs§

ParseError
An error returned when a request target cannot be parsed.
Parsed
The result of parsing an origin-form request target.

Functions§

parse_path_and_query
Parse a single origin-form request target exactly as nginx does.