From 5f346588e70e9a678523ac016981bda8e37e920f Mon Sep 17 00:00:00 2001 From: Yorick Peterse Date: Mon, 1 Jul 2024 00:35:22 +0800 Subject: [PATCH] Fix double slashes in search URLs Changelog: fixed --- src/idoc/html.inko | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/idoc/html.inko b/src/idoc/html.inko index 4fa5c2c..8597018 100644 --- a/src/idoc/html.inko +++ b/src/idoc/html.inko @@ -52,7 +52,10 @@ fn link(href: String, rel: String) -> Element { fn head(page: String, title: String) -> Element { let head = Element.new('head') - head.attr('data-to-root', relative_url(page, '/')) + # We remove the trailing / here so that in the JS code we can just do the + # equivalent of `data-to-root + link`, without ending up with duplicate + # slashes (e.g. foo.com//module/...) in the URLs. + head.attr('data-to-root', relative_url(page, '/').strip_suffix('/')) # The search data can get pretty big so we want to cache it. Since the file is # generated dynamically, we can't use inko-wobsite's asset hashing feature,