« get me outta code hell

client: make rebase() a bit more sensible - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src/static/js
diff options
context:
space:
mode:
author(quasar) nebula <qznebula@protonmail.com>2025-01-30 12:35:06 -0400
committer(quasar) nebula <qznebula@protonmail.com>2025-01-30 12:36:00 -0400
commitbac52b092c3b95b811bfe386751773893713b136 (patch)
treee56f6b6de663ecd19cf963ba418e2c61c2ee28d4 /src/static/js
parent331a9d67ffed63e3744eb4738977233727ab8cc3 (diff)
client: make rebase() a bit more sensible HEAD staging release
Diffstat (limited to 'src/static/js')
-rw-r--r--src/static/js/client-util.js17
1 files changed, 12 insertions, 5 deletions
diff --git a/src/static/js/client-util.js b/src/static/js/client-util.js
index f06b707a..71112313 100644
--- a/src/static/js/client-util.js
+++ b/src/static/js/client-util.js
@@ -1,12 +1,19 @@
 /* eslint-env browser */
 
 export function rebase(href, rebaseKey = 'rebaseLocalized') {
-  const relative = (document.documentElement.dataset[rebaseKey] || '.') + '/';
-  if (relative) {
-    return relative + href;
-  } else {
-    return href;
+  let result = document.documentElement.dataset[rebaseKey] || './';
+
+  if (!result.endsWith('/')) {
+    result += '/';
+  }
+
+  if (href.startsWith('/')) {
+    href = href.slice(1);
   }
+
+  result += href;
+
+  return result;
 }
 
 export function cssProp(el, ...args) {