urlpattern

Crates.iourlpattern
lib.rsurlpattern
version0.2.0
sourcesrc
created_at2021-09-07 13:28:02.12443
updated_at2022-05-06 12:47:11.090527
descriptionrust-urlpattern is a Rust implementation of the URLPattern standard
homepage
repositoryhttps://github.com/denoland/rust-urlpattern
max_upload_size
id447990
size176,366
David Sherret (dsherret)

documentation

README

urlpattern

This crate implements the URLPattern web API in Rust. We aim to follow the specification as closely as possible.

Example

use urlpattern::UrlPattern;
use urlpattern::UrlPatternInput;
use urlpattern::UrlPatternInit;

use urlpattern::UrlPattern;
use urlpattern::UrlPatternInit;
use urlpattern::UrlPatternMatchInput;

fn main() {
  // Create the UrlPattern to match against.
  let init = UrlPatternInit {
    pathname: Some("/users/:id".to_owned()),
    ..Default::default()
  };
  let pattern = <UrlPattern>::parse(init).unwrap();

  // Match the pattern against a URL.
  let url = "https://example.com/users/123".parse().unwrap();
  let result = pattern.exec(UrlPatternMatchInput::Url(url)).unwrap().unwrap();
  assert_eq!(result.pathname.groups.get("id").unwrap(), "123");
}

Contributing

We appreciate your help!

The code of conduct from the Deno repository applies here too: https://github.com/denoland/deno/blob/main/CODE_OF_CONDUCT.md.

Commit count: 34

cargo fmt