| Crates.io | surt-rs |
| lib.rs | surt-rs |
| version | 0.1.3 |
| created_at | 2024-03-23 13:52:59.089568+00 |
| updated_at | 2024-07-02 12:39:10.305411+00 |
| description | A Rust implementation of the Sort-friendly URI Reordering Transform (SURT) |
| homepage | |
| repository | https://github.com/mijho/surt-rs |
| max_upload_size | |
| id | 1183543 |
| size | 18,452 |
This library provides a Rust implementation for generating a Sort-friendly URI Reordering Transform (SURT) from a given URL. These are predominantly used in the Web Archiving world to provide a normalised and sortable variant of a URL for use at replay time.
use surt_rs::generate_surt;
let url = "http://example.com/path?query=value#fragment";
let surt = generate_surt(url).unwrap();
println!("{}", surt); // prints: "com,example)/path?query=value#fragment"
generate_surt(url: &str) -> Result<String, ParseError>Generates a SURT from the given URL. Returns a Result that contains the SURT as a String if the URL is valid, or a ParseError if the URL is not valid.
normalize_surt(surt: &str) -> StringNormalizes the given SURT by replacing whitespace with '%20' and removing trailing slashes unless it's the root path.
normalize_url(url: &str) -> StringNormalizes the given URL by removing trailing slashes and the 'www.' subdomain after the scheme.
This project is licensed under the MIT License.