700 releases

new 0.2.691 Mar 14, 2025
0.2.677 Feb 27, 2025
0.2.651 Dec 31, 2024
0.2.620 Nov 30, 2024
0.0.3 Nov 15, 2021

#287 in Parser implementations

Download history 1125/week @ 2024-11-22 1048/week @ 2024-11-29 1228/week @ 2024-12-06 974/week @ 2024-12-13 964/week @ 2024-12-20 924/week @ 2024-12-27 719/week @ 2025-01-03 869/week @ 2025-01-10 896/week @ 2025-01-17 617/week @ 2025-01-24 79/week @ 2025-01-31 159/week @ 2025-02-07 229/week @ 2025-02-14 208/week @ 2025-02-21 854/week @ 2025-02-28 809/week @ 2025-03-07

2,141 downloads per month
Used in 3 crates (2 directly)

MIT/Apache

480KB
11K SLoC

oni-comb-uri-rs

A Rust crate for URI.

Specification

This crate is based on the following specifications.

  • RFC3986: Uniform Resource Identifier (URI): Generic Syntax

Usage

use oni_comb_uri::uri::Uri;

let s = "http://user1:pass1@localhost:8080/example?key1=value1&key2=value2&key1=value2#f1";

match Uri::parse(s) {
  Ok(uri) => {
    uri.schema().into_iter().for_each(|s| assert_eq!(s.to_string(), "http"));
    uri
      .host_name()
      .into_iter()
      .for_each(|hn| assert_eq!(hn.to_string(), "localhost"));
    uri.port().into_iter().for_each(|p| assert_eq!(p, 8080));
    uri.user_info().into_iter().for_each(|ui| {
      assert_eq!(ui.user_name(), "user1");
      assert_eq!(ui.password(), Some("pass1"));
    });
    uri
      .path()
      .into_iter()
      .for_each(|p| assert_eq!(p.to_string(), "/example"));
    uri.query().into_iter().for_each(|q| {
      q.get_param("key1".to_string()).into_iter().for_each(|v| {
        assert_eq!(v.len(), 2);
        assert_eq!(v[0], "value1");
        assert_eq!(v[1], "value2");
      });
      q.get_param("key2".to_string()).into_iter().for_each(|v| {
        assert_eq!(v.len(), 1);
        assert_eq!(v[0], "value2");
      });
    });
    uri.fragment().into_iter().for_each(|f| assert_eq!(f, "f1"));
    println!("{:?}", uri);
  }
  Err(e) => println!("{:?}", e),
}

Dependencies

~2.2–3.5MB
~56K SLoC