path

Function path 

Source
pub fn path<S: Spec>(s: &str) -> Result<(), Error>
Expand description

Validates IRI path.

ยงExamples

use iri_string::{spec::UriSpec, validate::path};
assert!(path::<UriSpec>("").is_ok());
assert!(path::<UriSpec>("foo/bar").is_ok());
assert!(path::<UriSpec>("foo/bar/").is_ok());
assert!(path::<UriSpec>("/foo/bar").is_ok());
assert!(path::<UriSpec>("non-%99-utf-8").is_ok());
// Be careful! This is completely valid (absolute) path, but may be confused
// with an protocol-relative URI, with the authority `foo` and the path `/bar`.
assert!(path::<UriSpec>("//foo/bar").is_ok());
// Be careful! This is completely valid (relative) path, but may be confused
// with an absolute URI, with the scheme `foo` and the path `bar`.
assert!(path::<UriSpec>("foo:bar").is_ok());

// Invalid characters.
assert!(path::<UriSpec>("foo?bar").is_err());
assert!(path::<UriSpec>("foo#bar").is_err());