« get me outta code hell

hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src/find.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/find.js')
-rw-r--r--src/find.js10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/find.js b/src/find.js
index 78775457..c8edce98 100644
--- a/src/find.js
+++ b/src/find.js
@@ -16,7 +16,10 @@ function warnOrThrow(mode, message) {
 }
 
 export function processAllAvailableMatches(data, {
-  getMatchableNames = thing => [thing.name],
+  getMatchableNames = thing =>
+    (Object.hasOwn(thing, 'name')
+      ? [thing.name]
+      : []),
 } = {}) {
   const byName = Object.create(null);
   const byDirectory = Object.create(null);
@@ -24,6 +27,11 @@ export function processAllAvailableMatches(data, {
 
   for (const thing of data) {
     for (const name of getMatchableNames(thing)) {
+      if (typeof name !== 'string') {
+        logWarn`Unexpected ${typeAppearance(name)} returned in names for ${inspect(thing)}`;
+        continue;
+      }
+
       const normalizedName = name.toLowerCase();
       if (normalizedName in byName) {
         byName[normalizedName] = null;