diff --git a/moli-renderer-v8/src/context_bootstrap/location_runtime/navigation.rs b/moli-renderer-v8/src/context_bootstrap/location_runtime/navigation.rs index 28da946b8e7..b168eea3e35 100644 --- a/moli-renderer-v8/src/context_bootstrap/location_runtime/navigation.rs +++ b/moli-renderer-v8/src/context_bootstrap/location_runtime/navigation.rs @@ -13,11 +13,7 @@ pub(in crate::context_bootstrap) fn resolve_location_navigation_target( url::Url::parse(raw_target.as_deref().unwrap_or(current_href)).ok() } LocationNavigationKind::Assign | LocationNavigationKind::Replace => { - let raw_target = raw_target.unwrap_or_default(); - if raw_target.is_empty() { - return url::Url::parse(current_href).ok(); - } - + let raw_target = raw_target?; if let Ok(absolute) = url::Url::parse(&raw_target) { return Some(absolute); } diff --git a/moli-renderer-v8/src/script_vm/tests/browser_api/navigation/history_api.rs b/moli-renderer-v8/src/script_vm/tests/browser_api/navigation/history_api.rs index 206f58dbe47..be29027acea 100644 --- a/moli-renderer-v8/src/script_vm/tests/browser_api/navigation/history_api.rs +++ b/moli-renderer-v8/src/script_vm/tests/browser_api/navigation/history_api.rs @@ -592,3 +592,35 @@ fn location_hash_empty_fragment_serializes_empty_and_clears_target() { assert_eq!(result, "#target/true|true||false|true"); } + +#[test] +fn empty_location_urls_follow_the_live_entry_document_base() { + for operation in [ + "location.href = input", + "location.assign(input)", + "location.replace(input)", + ] { + let mut vm = new_parsed_test_vm( + "https://navigation-base.test/entry/page.html", + "