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

#144 in Web programming

Download history 42089/week @ 2024-11-15 40498/week @ 2024-11-22 46668/week @ 2024-11-29 48769/week @ 2024-12-06 49182/week @ 2024-12-13 36252/week @ 2024-12-20 37263/week @ 2024-12-27 49538/week @ 2025-01-03 49512/week @ 2025-01-10 52874/week @ 2025-01-17 61996/week @ 2025-01-24 54501/week @ 2025-01-31 58260/week @ 2025-02-07 58454/week @ 2025-02-14 64478/week @ 2025-02-21 50802/week @ 2025-02-28

241,074 downloads per month
Used in 232 crates (12 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–6.5MB
~110K SLoC