diff options
-rw-r--r-- | src/find.js | 60 |
1 files changed, 30 insertions, 30 deletions
diff --git a/src/find.js b/src/find.js index b2d32f80..2c97142f 100644 --- a/src/find.js +++ b/src/find.js @@ -141,24 +141,23 @@ function findHelper({ const {key: keyPart, ref: refPart} = regexMatch.groups; - if (keyPart && !referenceTypes.includes(keyPart)) { - return warnOrThrow(mode, - `Reference starts with "${keyPart}:", expected ` + - referenceTypes.map(type => `"${type}:"`).join(', ')); - } + let match; + + if (keyPart) { + if (!referenceTypes.includes(keyPart)) { + return warnOrThrow(mode, + `Reference starts with "${keyPart}:", expected ` + + referenceTypes.map(type => `"${type}:"`).join(', ')); + } - const normalizedName = - (keyPart - ? null - : refPart.toLowerCase()); + match = subcache.byDirectory[refPart]; + } else { + const normalizedName = + refPart.toLowerCase(); - const match = - (keyPart - ? subcache.byDirectory[refPart] - : subcache.byName[normalizedName]); + match = subcache.byName[normalizedName]; - if (!match && !keyPart) { - if (subcache.multipleNameMatches[normalizedName]) { + if (!match && subcache.multipleNameMatches[normalizedName]) { return warnOrThrow(mode, `Multiple matches for reference "${fullRef}". Please resolve:\n` + subcache.multipleNameMatches[normalizedName] @@ -293,24 +292,25 @@ function findMixedHelper(config) { const {key: keyPart, ref: refPart} = regexMatch.groups; - if (keyPart && !referenceTypes.includes(keyPart)) { - return warnOrThrow(mode, - `Reference starts with "${keyPart}:", expected ` + - referenceTypes.map(type => `"${type}:"`).join(', ')); - } + let match; + + if (keyPart) { + if (!referenceTypes.includes(keyPart)) { + return warnOrThrow(mode, + `Reference starts with "${keyPart}:", expected ` + + referenceTypes.map(type => `"${type}:"`).join(', ')); + } - const normalizedName = - (keyPart - ? null - : refPart.toLowerCase()); + // TODO: Do something + match = null; + } else { + const normalizedName = + refPart.toLowerCase(); - const match = - (keyPart - ? null /* TODO: Do something */ - : byName[normalizedName]); + match = + byName[normalizedName]; - if (!match && !keyPart) { - if (multipleNameMatches[normalizedName]) { + if (!match && multipleNameMatches[normalizedName]) { return warnOrThrow(mode, `Multiple matches for reference "${fullRef}". Please resolve:\n` + multipleNameMatches[normalizedName] |