8 releases

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

#950 in Web programming

Download history 6459/week @ 2023-11-21 5387/week @ 2023-11-28 5710/week @ 2023-12-05 5750/week @ 2023-12-12 3760/week @ 2023-12-19 2259/week @ 2023-12-26 5296/week @ 2024-01-02 6023/week @ 2024-01-09 5675/week @ 2024-01-16 6304/week @ 2024-01-23 6096/week @ 2024-01-30 5536/week @ 2024-02-06 4638/week @ 2024-02-13 5260/week @ 2024-02-20 5108/week @ 2024-02-27 6734/week @ 2024-03-05

22,469 downloads per month
Used in 90 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