| Crates.io | path2regex |
| lib.rs | path2regex |
| version | 0.0.4 |
| created_at | 2022-11-13 13:29:23.991212+00 |
| updated_at | 2022-12-02 17:56:56.49641+00 |
| description | Express style path to RegExp utility |
| homepage | |
| repository | https://github.com/Binbiubiubiu/path2regex |
| max_upload_size | |
| id | 714202 |
| size | 92,229 |
cargo add path2regex
Similar to path-to-regex
Thought that regex was not supported ?=,The performance of the end and ends_with property in the configuration item will vary.
notice: regex executes captures to get the result, providing the name END_WITH_DELIMITER matching group to handle the extra endings
let re = path2regex::PathRegexBuilder::new("/test")
.set_end(false)
.build()
.unwrap();
// expected: Captures({0: Some("/test")})
// found: Captures({0: Some("/test"), "END_WIND_DELIMITER": Some("")})
println!("{:?}", re.captures("/test").unwrap());
// expected: Captures({0: Some("/test")})
// found: Captures({0: Some("/test/"), "END_WIND_DELIMITER": Some("")})
println!("{:?}", re.captures("/test/").unwrap());
// expected: Captures({0: Some("/test")})
// found: Captures({0: Some("/test/"), "END_WIND_DELIMITER": Some("/")})
println!("{:?}", re.captures("/test/route").unwrap());