Skip to main content

Options

Struct Options 

Source
pub struct Options {
Show 20 fields pub default_protocol: Protocol, pub custom_protocols: Vec<String>, pub normalize_protocol: bool, pub force_http: bool, pub force_https: bool, pub strip_authentication: bool, pub strip_hash: bool, pub strip_protocol: bool, pub strip_text_fragment: bool, pub strip_www: bool, pub remove_query_parameters: RemoveQueryParameters, pub keep_query_parameters: Option<Vec<QueryFilter>>, pub remove_trailing_slash: bool, pub remove_single_slash: bool, pub remove_directory_index: RemoveDirectoryIndex, pub remove_explicit_port: bool, pub sort_query_parameters: bool, pub empty_query_value: EmptyQueryValue, pub remove_path: bool, pub transform_path: Option<TransformPathFn>,
}
Expand description

Options for URL normalization.

All options have sensible defaults matching the behavior of the original normalize-url npm package.

Fields§

§default_protocol: Protocol

Default protocol to prepend if missing.

Default: Protocol::Http

§custom_protocols: Vec<String>

Additional protocols to normalize (beyond http, https, file, data). Protocols should be specified without :.

Default: vec![]

§normalize_protocol: bool

Prepend default_protocol to protocol-relative URLs.

Default: true

§force_http: bool

Normalize HTTPS to HTTP.

Default: false

§force_https: bool

Normalize HTTP to HTTPS. Cannot be used with force_http.

Default: false

§strip_authentication: bool

Strip the authentication part of the URL.

Default: true

§strip_hash: bool

Strip the hash/fragment part of the URL.

Default: false

§strip_protocol: bool

Remove the protocol from the URL.

Default: false

§strip_text_fragment: bool

Strip the text fragment part of the URL (#:~:text=...).

Default: true

§strip_www: bool

Remove www. from the URL.

Default: true

§remove_query_parameters: RemoveQueryParameters

Controls removal of query parameters.

Default: RemoveQueryParameters::List with a single filter matching utm_*

§keep_query_parameters: Option<Vec<QueryFilter>>

If set, only keep query parameters matching these filters. Overrides remove_query_parameters.

Default: None

§remove_trailing_slash: bool

Remove trailing slash from the path.

Default: true

§remove_single_slash: bool

Remove a sole / pathname in the output.

Default: true

§remove_directory_index: RemoveDirectoryIndex

Remove directory index files matching the given filters.

Default: RemoveDirectoryIndex::None

§remove_explicit_port: bool

Remove explicit port numbers.

Default: false

§sort_query_parameters: bool

Sort query parameters alphabetically by key.

Default: true

§empty_query_value: EmptyQueryValue

Controls how empty query parameter values are formatted.

Default: EmptyQueryValue::Preserve

§remove_path: bool

Remove the entire URL path, leaving only the domain.

Default: false

§transform_path: Option<TransformPathFn>

Custom function to transform path components.

Default: None

Trait Implementations§

Source§

impl Default for Options

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.