From 72a811ae2c5aef43144b2a95f0dcf2e72465e005 Mon Sep 17 00:00:00 2001 From: Tal Hayon Date: Sun, 12 Sep 2021 18:00:36 +0300 Subject: [PATCH] web: support no trailing slash in base parameter --- web/src/navigator.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/web/src/navigator.rs b/web/src/navigator.rs index 34d2eb952..867119e15 100644 --- a/web/src/navigator.rs +++ b/web/src/navigator.rs @@ -31,11 +31,16 @@ impl WebNavigatorBackend { let window = web_sys::window().expect("window()"); let performance = window.performance().expect("window.performance()"); - // Upgarde to HTTPS takes effect if the current page is hosted on HTTPS. + // Upgrade to HTTPS takes effect if the current page is hosted on HTTPS. let upgrade_to_https = upgrade_to_https && window.location().protocol().unwrap_or_default() == "https:"; - if let Some(ref base) = base_url { + if let Some(base) = &mut base_url { + // Adding trailing slash so url::parse will not drop last part + if !base.ends_with('/') { + base.push('/'); + } + if Url::parse(base).is_err() { let document = window.document().expect("Could not get document"); if let Ok(Some(doc_base_uri)) = document.base_uri() {