« get me outta code hell

hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src/urls.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/urls.js')
-rw-r--r--src/urls.js34
1 files changed, 22 insertions, 12 deletions
diff --git a/src/urls.js b/src/urls.js
index 83a8b904..b51ea459 100644
--- a/src/urls.js
+++ b/src/urls.js
@@ -129,6 +129,9 @@ export function generateURLs(urlSpec) {
         if (template === null) {
           // Self-diagnose, brutally.
 
+          // TODO: This variable isn't used, and has never been used,
+          // but it might have been *meant* to be used?
+          // eslint-disable-next-line no-unused-vars
           const otherTemplateKey = (device ? 'posix' : 'device');
 
           const {value: {[templateKey]: otherTemplate}} =
@@ -283,9 +286,14 @@ export function getURLsFrom({
       to = targetFullKey;
     }
 
-    return (
-      subdirectoryPrefix +
-      urls.from(from).to(to, ...args));
+    const toResult =
+      urls.from(from).to(to, ...args);
+
+    if (getOrigin(toResult)) {
+      return toResult;
+    } else {
+      return subdirectoryPrefix + toResult;
+    }
   };
 }
 
@@ -300,16 +308,18 @@ export function getURLsFromRoot({
 
   return (targetFullKey, ...args) => {
     const [groupKey, subKey] = targetFullKey.split('.');
-    return (
-      '/' +
+    const toResult =
       (groupKey === 'localized' && baseDirectory
-        ? to(
-            'localizedWithBaseDirectory.' + subKey,
-            baseDirectory,
-            ...args
-          )
-        : to(targetFullKey, ...args))
-    );
+        ? to('localizedWithBaseDirectory.' + subKey, baseDirectory, ...args)
+     : groupKey === 'localizedDefaultLanguage'
+        ? to('localized.' + subKey, ...args)
+        : to(targetFullKey, ...args));
+
+    if (getOrigin(toResult)) {
+      return toResult;
+    } else {
+      return '/' + toResult;
+    }
   };
 }