« get me outta code hell

hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src/data
diff options
context:
space:
mode:
Diffstat (limited to 'src/data')
-rw-r--r--src/data/things/Language.js47
1 files changed, 35 insertions, 12 deletions
diff --git a/src/data/things/Language.js b/src/data/things/Language.js
index dc8c0368..8b8c78b7 100644
--- a/src/data/things/Language.js
+++ b/src/data/things/Language.js
@@ -732,31 +732,49 @@ export class Language extends Thing {
       : duration;
   }
 
-  formatExternalLink(url, {
+  formatExternalLink(urlEntry, {
     style = 'platform',
     context = 'generic',
   } = {}) {
     // Null or undefined url is blank content.
-    if (url === null || url === undefined) {
+    if (urlEntry === null || urlEntry === undefined) {
       return html.blank();
     }
 
+    // String means we're probably receiving a URL, not a URL entry.
+    // Just fill in blanks like from a mock/dummy entry.
+    if (typeof urlEntry === 'string') {
+      return this.formatExternalLink(
+        {
+          url: urlEntry,
+          annotation: null,
+        },
+        {style, context});
+    }
+
     isExternalLinkContext(context);
 
     if (style === 'all') {
-      return getExternalLinkStringsFromDescriptors(url, externalLinkSpec, {
-        language: this,
-        context,
-      });
+      return getExternalLinkStringsFromDescriptors(
+        urlEntry,
+        externalLinkSpec,
+        {
+          language: this,
+          context,
+        });
     }
 
     isExternalLinkStyle(style);
 
     const result =
-      getExternalLinkStringOfStyleFromDescriptors(url, style, externalLinkSpec, {
-        language: this,
-        context,
-      });
+      getExternalLinkStringOfStyleFromDescriptors(
+        urlEntry,
+        style,
+        externalLinkSpec,
+        {
+          language: this,
+          context,
+        });
 
     // It's possible for there to not actually be any string available for the
     // given URL, style, and context, and we want this to be detectable via
@@ -803,11 +821,16 @@ export class Language extends Thing {
   }
 
   #formatListHelper(array, processFn) {
+    // Empty lists, null, and undefined are blank content.
+    if (empty(array) || array === null || array === undefined) {
+      return html.blank();
+    }
+
     // Blank items aren't for display.
     array = array.filter(item => !html.isBlank(item));
 
-    // Empty lists, null, and undefined are blank content.
-    if (empty(array) || array === null || array === undefined) {
+    // Empty lists are blank content.  (2, The Sequel)
+    if (empty(array)) {
       return html.blank();
     }