mirror of
https://github.com/servo/servo.git
synced 2025-09-30 00:29:14 +01:00
Allow domain-like as URL location input (#35756)
* Allow domain-like as URL location input Before this patch, domain with subdomain (e.g. book.servo.org) won't be treated as URL location. This patch retifies that by adding Firefox's location bar behavior: - book.servo.org is URL location - book.servo.org. is URL location - .book.servo.org is not URL location Fixes #35754. Signed-off-by: Kafji <k@kafji.net> * Chain location input interpretation attempts Signed-off-by: Kafji <k@kafji.net> --------- Signed-off-by: Kafji <k@kafji.net>
This commit is contained in:
parent
48aacc43b7
commit
34047f8da8
2 changed files with 94 additions and 9 deletions
|
@ -220,3 +220,66 @@ fn test_cmd_and_location_bar_url() {
|
|||
"file:///dev/null",
|
||||
);
|
||||
}
|
||||
|
||||
/// Like [test_url] but will produce test for Windows or non Windows using `#[cfg(target_os)]` internally.
|
||||
fn test_url_any_os(
|
||||
input: &str,
|
||||
location: &str,
|
||||
#[allow(unused)] if_exists: &str,
|
||||
#[allow(unused)] if_exists_windows: &str,
|
||||
otherwise: &str,
|
||||
) {
|
||||
#[cfg(not(target_os = "windows"))]
|
||||
test_url(input, location, if_exists, otherwise);
|
||||
|
||||
#[cfg(target_os = "windows")]
|
||||
test_url(input, location, if_exists_windows, otherwise);
|
||||
}
|
||||
|
||||
// https://github.com/servo/servo/issues/35754
|
||||
#[test]
|
||||
fn test_issue_35754() {
|
||||
test_url_any_os(
|
||||
"leah.chromebooks.lol",
|
||||
"https://leah.chromebooks.lol/",
|
||||
"file:///fake/cwd/leah.chromebooks.lol",
|
||||
"file:///C:/fake/cwd/leah.chromebooks.lol",
|
||||
"https://leah.chromebooks.lol/",
|
||||
);
|
||||
|
||||
// ends with dot
|
||||
test_url_any_os(
|
||||
"leah.chromebooks.lol.",
|
||||
"https://leah.chromebooks.lol./",
|
||||
"file:///fake/cwd/leah.chromebooks.lol.",
|
||||
"file:///C:/fake/cwd/leah.chromebooks.lol.",
|
||||
"https://leah.chromebooks.lol./",
|
||||
);
|
||||
|
||||
// starts with dot
|
||||
test_url_any_os(
|
||||
".leah.chromebooks.lol",
|
||||
"https://duckduckgo.com/html/?q=.leah.chromebooks.lol",
|
||||
"file:///fake/cwd/.leah.chromebooks.lol",
|
||||
"file:///C:/fake/cwd/.leah.chromebooks.lol",
|
||||
"https://duckduckgo.com/html/?q=.leah.chromebooks.lol",
|
||||
);
|
||||
|
||||
// contains spaces
|
||||
test_url_any_os(
|
||||
"3.5 kg in lb",
|
||||
"https://duckduckgo.com/html/?q=3.5%20kg%20in%20lb",
|
||||
"file:///fake/cwd/3.5%20kg%20in%20lb",
|
||||
"file:///C:/fake/cwd/3.5%20kg%20in%20lb",
|
||||
"https://duckduckgo.com/html/?q=3.5%20kg%20in%20lb",
|
||||
);
|
||||
|
||||
// user-local domain
|
||||
test_url_any_os(
|
||||
"foo/bar",
|
||||
"https://foo/bar",
|
||||
"file:///fake/cwd/foo/bar",
|
||||
"file:///C:/fake/cwd/foo/bar",
|
||||
"https://foo/bar",
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue