fix: convert JS template expressions to glob wildcards in pattern mat…#3
Conversation
…ching
`resolvePattern` preserved `${...}` template syntax verbatim, but Go's
`path.Match` doesn't recognize it — so `new URL(`./images/${code}.webp`)`
never matched sibling assets like `blockchain.webp`. Replace `${...}` with
`*` before glob matching.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Code Review
This pull request introduces support for resolving template literal patterns (e.g., ${code}) in asset references by replacing them with a wildcard * before resolving aliases. A new regular expression templateExprRe is added to match these expressions, and a corresponding unit test is introduced to verify the resolution of template literal patterns. There are no review comments, and I have no additional feedback to provide.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
Summary
resolvePatternpreserved${...}template literal syntax verbatim, but Go'spath.Matchdoesn't recognize JS template expressions — causing dynamic references likenew URL(`./images/${code}.webp`, import.meta.url)to never match sibling assetstemplateExprReto replace${...}with*glob wildcards before matching, so./images/${code}.webpbecomes./images/*.webpProblem
Files referenced via JS template literals were incorrectly reported as unused:
Extract()correctly identified this as apatternkind, butresolvePattern()passed${category}through toglobMatchRepoPath(), wherepath.Match("${category}.webp", "apple.webp")returnedfalse.Test plan
go test ./internal/references/ -run TestBuildMapResolvesTemplateLiteralPattern -v— PASSgo test ./internal/references/ -v— all existing tests still pass