|
| 1 | +use satex_core::util::{canonicalize, remove_end_sep, remove_start_sep}; |
| 2 | + |
| 3 | +#[test] |
| 4 | +fn test_canonicalize() { |
| 5 | + assert_eq!("/api/v1/resource", canonicalize("/api/v1/resource")); |
| 6 | + assert_eq!("/api/resource", canonicalize("/api/v1/../resource")); |
| 7 | + assert_eq!("/api/v1/resource", canonicalize("/api/v1/./resource")); |
| 8 | + assert_eq!("/api/resource", canonicalize("/api/v1/./../resource")); |
| 9 | + assert_eq!("/", canonicalize("/..")); |
| 10 | + assert_eq!("/", canonicalize("../..")); |
| 11 | + assert_eq!("/", canonicalize("/.")); |
| 12 | + assert_eq!("/", canonicalize("./.")); |
| 13 | +} |
| 14 | + |
| 15 | +#[test] |
| 16 | +fn test_remove_start_sep() { |
| 17 | + assert_eq!("api/vi/resource", remove_start_sep("api/vi/resource")); |
| 18 | + assert_eq!("api/vi/resource", remove_start_sep("/api/vi/resource")); |
| 19 | + assert_eq!("api/vi/resource", remove_start_sep("//api/vi/resource")); |
| 20 | + assert_eq!("api/vi/resource", remove_start_sep("///api/vi/resource")); |
| 21 | + assert_eq!("", remove_start_sep("///////////////////")); |
| 22 | + assert_eq!("a", remove_start_sep("///////////////////a")); |
| 23 | +} |
| 24 | + |
| 25 | +#[test] |
| 26 | +fn test_remove_end_sep() { |
| 27 | + assert_eq!("/api/vi/resource", remove_end_sep("/api/vi/resource")); |
| 28 | + assert_eq!("/api/vi/resource", remove_end_sep("/api/vi/resource/")); |
| 29 | + assert_eq!("/api/vi/resource", remove_end_sep("/api/vi/resource//")); |
| 30 | + assert_eq!("/api/vi/resource", remove_end_sep("/api/vi/resource///")); |
| 31 | + assert_eq!("", remove_end_sep("///////////////////")); |
| 32 | + assert_eq!("a", remove_end_sep("a///////////////////")); |
| 33 | +} |
0 commit comments