2020-03-23 03:08:41 +01:00
|
|
|
// ██████╗ █████╗ ███████╗███████╗██╗███╗ ██╗ ██████╗
|
|
|
|
// ██╔══██╗██╔══██╗██╔════╝██╔════╝██║████╗ ██║██╔════╝
|
|
|
|
// ██████╔╝███████║███████╗███████╗██║██╔██╗ ██║██║ ███╗
|
|
|
|
// ██╔═══╝ ██╔══██║╚════██║╚════██║██║██║╚██╗██║██║ ██║
|
|
|
|
// ██║ ██║ ██║███████║███████║██║██║ ╚████║╚██████╔╝
|
|
|
|
// ╚═╝ ╚═╝ ╚═╝╚══════╝╚══════╝╚═╝╚═╝ ╚═══╝ ╚═════╝
|
|
|
|
|
2020-05-23 09:49:04 +02:00
|
|
|
#[cfg(test)]
|
|
|
|
mod passing {
|
2021-03-11 23:44:02 +01:00
|
|
|
use reqwest::Url;
|
|
|
|
|
2021-10-17 09:16:37 +02:00
|
|
|
use monolith::url;
|
2020-03-23 03:08:41 +01:00
|
|
|
|
2021-03-11 23:44:02 +01:00
|
|
|
#[test]
|
|
|
|
fn preserve_original() {
|
|
|
|
let u: Url = Url::parse("https://somewhere.com/font.eot#iefix").unwrap();
|
|
|
|
|
|
|
|
url::clean_url(u.clone());
|
|
|
|
|
|
|
|
assert_eq!(u.as_str(), "https://somewhere.com/font.eot#iefix");
|
|
|
|
}
|
|
|
|
|
2020-05-23 09:49:04 +02:00
|
|
|
#[test]
|
|
|
|
fn removes_fragment() {
|
|
|
|
assert_eq!(
|
2021-03-11 23:44:02 +01:00
|
|
|
url::clean_url(Url::parse("https://somewhere.com/font.eot#iefix").unwrap()).as_str(),
|
2020-05-23 09:49:04 +02:00
|
|
|
"https://somewhere.com/font.eot"
|
|
|
|
);
|
|
|
|
}
|
2020-03-23 03:08:41 +01:00
|
|
|
|
2020-05-23 09:49:04 +02:00
|
|
|
#[test]
|
|
|
|
fn removes_empty_fragment() {
|
|
|
|
assert_eq!(
|
2021-03-11 23:44:02 +01:00
|
|
|
url::clean_url(Url::parse("https://somewhere.com/font.eot#").unwrap()).as_str(),
|
2020-05-23 09:49:04 +02:00
|
|
|
"https://somewhere.com/font.eot"
|
|
|
|
);
|
|
|
|
}
|
2020-04-11 02:43:29 +02:00
|
|
|
|
2020-05-23 09:49:04 +02:00
|
|
|
#[test]
|
2021-03-11 23:44:02 +01:00
|
|
|
fn removes_empty_fragment_and_keeps_empty_query() {
|
2020-05-23 09:49:04 +02:00
|
|
|
assert_eq!(
|
2021-03-11 23:44:02 +01:00
|
|
|
url::clean_url(Url::parse("https://somewhere.com/font.eot?#").unwrap()).as_str(),
|
|
|
|
"https://somewhere.com/font.eot?"
|
2020-05-23 09:49:04 +02:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
2021-03-11 23:44:02 +01:00
|
|
|
fn removesempty_fragment_and_keeps_empty_query() {
|
2020-05-23 09:49:04 +02:00
|
|
|
assert_eq!(
|
2021-03-11 23:44:02 +01:00
|
|
|
url::clean_url(Url::parse("https://somewhere.com/font.eot?a=b&#").unwrap()).as_str(),
|
|
|
|
"https://somewhere.com/font.eot?a=b&"
|
2020-05-23 09:49:04 +02:00
|
|
|
);
|
|
|
|
}
|
2020-04-26 02:59:34 +02:00
|
|
|
|
2020-05-23 09:49:04 +02:00
|
|
|
#[test]
|
|
|
|
fn keeps_credentials() {
|
|
|
|
assert_eq!(
|
2021-03-11 23:44:02 +01:00
|
|
|
url::clean_url(Url::parse("https://cookie:monster@gibson.internet/").unwrap()).as_str(),
|
2020-05-23 09:49:04 +02:00
|
|
|
"https://cookie:monster@gibson.internet/"
|
|
|
|
);
|
|
|
|
}
|
2020-04-26 02:59:34 +02:00
|
|
|
}
|