Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/denoland/rust-urlpattern
Rust implementation of the `URLPattern` web API
https://github.com/denoland/rust-urlpattern
rust urlpattern web
Last synced: 3 days ago
JSON representation
Rust implementation of the `URLPattern` web API
- Host: GitHub
- URL: https://github.com/denoland/rust-urlpattern
- Owner: denoland
- License: mit
- Created: 2021-08-14T11:44:27.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2024-07-31T15:21:53.000Z (7 months ago)
- Last Synced: 2025-02-02T05:29:42.875Z (10 days ago)
- Topics: rust, urlpattern, web
- Language: Rust
- Homepage:
- Size: 81.1 KB
- Stars: 60
- Watchers: 16
- Forks: 18
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# urlpattern
This crate implements the [`URLPattern` web API][urlpattern] in Rust. We aim to
follow [the specification][spec] as closely as possible.[urlpattern]: https://github.com/WICG/urlpattern
[spec]: https://wicg.github.io/urlpattern/## Example
```rust
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 = ::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.