« get me outta code hell

hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--src/util/urls.js12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/util/urls.js b/src/util/urls.js
index 69ff1d7e..78bcd200 100644
--- a/src/util/urls.js
+++ b/src/util/urls.js
@@ -186,22 +186,25 @@ export function getURLsFrom({
 
 export function getPagePathname({
   baseDirectory,
+  device = false,
   fullKey,
   urlArgs,
   urls,
 }) {
   const [groupKey, subKey] = fullKey.split('.');
 
+  const toKey = device ? 'toDevice' : 'to';
+
   return (groupKey === 'localized' && baseDirectory
     ? urls
-        .from('shared.root')
-        .toDevice(
+        .from('shared.root')[toKey](
           'localizedWithBaseDirectory.' + subKey,
           baseDirectory,
           ...urlArgs)
     : urls
-        .from('shared.root')
-        .toDevice(fullKey, ...urlArgs));
+        .from('shared.root')[toKey](
+          fullKey,
+          ...urlArgs));
 }
 
 // Needed for the rare path arguments which themselves contains one or more
@@ -221,6 +224,7 @@ export function getPagePaths({
 
   const pathname = getPagePathname({
     baseDirectory,
+    device: true,
     fullKey,
     urlArgs,
     urls,