9 releases

0.3.0 Jul 31, 2024
0.2.0 May 6, 2022
0.1.6 Jan 25, 2022
0.1.2 Sep 7, 2021

#96 in Web programming

Download history 20967/week @ 2024-07-30 22066/week @ 2024-08-06 20136/week @ 2024-08-13 19612/week @ 2024-08-20 22323/week @ 2024-08-27 25718/week @ 2024-09-03 22680/week @ 2024-09-10 20957/week @ 2024-09-17 21776/week @ 2024-09-24 33156/week @ 2024-10-01 34392/week @ 2024-10-08 34653/week @ 2024-10-15 33976/week @ 2024-10-22 38934/week @ 2024-10-29 40401/week @ 2024-11-05 39945/week @ 2024-11-12

159,880 downloads per month
Used in 193 crates (11 directly)

MIT license

105KB
3K 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/.github/CODE_OF_CONDUCT.md.

Dependencies

~4.5–6.5MB
~111K SLoC