8 releases

0.2.0 May 6, 2022
0.1.6 Jan 25, 2022
0.1.2 Sep 7, 2021

#305 in Web programming

Download history 5757/week @ 2023-12-11 4409/week @ 2023-12-18 2105/week @ 2023-12-25 4813/week @ 2024-01-01 6143/week @ 2024-01-08 5377/week @ 2024-01-15 6565/week @ 2024-01-22 5816/week @ 2024-01-29 5883/week @ 2024-02-05 4622/week @ 2024-02-12 4861/week @ 2024-02-19 5419/week @ 2024-02-26 7554/week @ 2024-03-04 9446/week @ 2024-03-11 10829/week @ 2024-03-18 9759/week @ 2024-03-25

38,159 downloads per month
Used in 94 crates (8 directly)

MIT license

96KB
2.5K SLoC

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.

Dependencies

~4–6MB
~138K SLoC