« get me outta code hell

hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/find.js14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/find.js b/src/find.js
index c8edce98..5a249c28 100644
--- a/src/find.js
+++ b/src/find.js
@@ -34,11 +34,12 @@ export function processAllAvailableMatches(data, {
 
       const normalizedName = name.toLowerCase();
       if (normalizedName in byName) {
+        const alreadyMatchesByName = byName[normalizedName];
         byName[normalizedName] = null;
         if (normalizedName in multipleNameMatches) {
           multipleNameMatches[normalizedName].push(thing);
         } else {
-          multipleNameMatches[normalizedName] = [thing];
+          multipleNameMatches[normalizedName] = [alreadyMatchesByName, thing];
         }
       } else {
         byName[normalizedName] = thing;
@@ -97,16 +98,21 @@ function findHelper({
     const typePart = regexMatch[1];
     const refPart = regexMatch[2];
 
+    const normalizedName =
+      (typePart
+        ? null
+        : refPart.toLowerCase());
+
     const match =
       (typePart
         ? subcache.byDirectory[refPart]
-        : subcache.byName[refPart.toLowerCase()]);
+        : subcache.byName[normalizedName]);
 
     if (!match && !typePart) {
-      if (subcache.multipleNameMatches[refPart]) {
+      if (subcache.multipleNameMatches[normalizedName]) {
         return warnOrThrow(mode,
           `Multiple matches for reference "${fullRef}". Please resolve:\n` +
-          subcache.multipleNameMatches[refPart]
+          subcache.multipleNameMatches[normalizedName]
             .map(match => `- ${inspect(match)}\n`)
             .join('') +
           `Returning null for this reference.`);