#web

urlpattern

rust-urlpattern is a Rust implementation of the URLPattern standard

8 releases

Uses new Rust 2021

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

#333 in Web programming

Download history 1568/week @ 2022-06-06 1715/week @ 2022-06-13 1818/week @ 2022-06-20 2057/week @ 2022-06-27 1790/week @ 2022-07-04 1848/week @ 2022-07-11 1891/week @ 2022-07-18 1708/week @ 2022-07-25 1824/week @ 2022-08-01 1727/week @ 2022-08-08 2085/week @ 2022-08-15 2213/week @ 2022-08-22 2092/week @ 2022-08-29 2545/week @ 2022-09-05 2399/week @ 2022-09-12 2308/week @ 2022-09-19

9,505 downloads per month
Used in 19 crates (via deno_url)

MIT license

95KB
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

~2.7–4MB
~121K SLoC