fix(router): prefer exact tier match over word-prefix fallback in parseTier - #538
Open
BlueX888 wants to merge 1 commit into
Open
fix(router): prefer exact tier match over word-prefix fallback in parseTier#538BlueX888 wants to merge 1 commit into
BlueX888 wants to merge 1 commit into
Conversation
…seTier The token-saver fallback parser iterated knownTiers in order with a word-boundary regex. Because '-' is a word boundary, a tier that is a word-prefix of a hyphenated tier (e.g. 'fast' vs 'fast-pro') matched first and won even when the judge output named the longer tier exactly. Check exact (case-insensitive) equality against known tiers before the regex fallback, and sort fallback candidates longest-first so free-text mentions also resolve to the most specific tier. Fixes OpenBMB#428
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
parseTiernow checks whether the cleaned judge output exactly equals a known tier (case-insensitively) before falling back to word-boundary matching, and the fallback iterates tiers longest-first.Why
The fallback loop iterated
knownTiersin configuration order with a\b<tier>\bregex. Since-is a word boundary, a tier that is a word-prefix of a hyphenated tier matched first: with tiersfastandfast-pro, a bare judge output offast-prowas parsed asfast. Reproduced onmain:How verified
tests/router/parseTier.spec.ts(6 cases: exact match over prefix, case-insensitive exact match, tagged output, free-text longest match, plain fallback mention, no-match returns undefined) — all pass viatsx --test.tests/router/tokenSaver.spec.ts(7 cases) still passes.tsc --noEmit -p tsconfig.jsonpasses.Fixes #428