Skip to content

fix(langneg): ignore whitespace-only language entries - #679

Open
poplolioi11 wants to merge 1 commit into
projectfluent:mainfrom
poplolioi11:fix/langneg-empty-language-items-675
Open

poplolioi11 wants to merge 1 commit into
projectfluent:mainfrom
poplolioi11:fix/langneg-empty-language-items-675

Conversation

@poplolioi11

Copy link
Copy Markdown

Current main retains whitespace-only list elements as empty strings in acceptedLanguages. For example, en-US, ,\t, fr produces ["en-US", "", "", "fr"]; empty entries also get the default quality of 1 and can precede actual language tags.

Trim the captured language once and skip it when empty before adding it to the sorting array. Preserve quality parsing, source indices and ordering of nonempty entries. This restores the previous empty-item behavior; published @fluent/langneg@0.7.0 is unaffected by this regression.

Fixes #675. Ignoring reasonable empty list elements follows RFC 9110 section 5.6.1.2.

Validation on main 9a925d2:

  • Original source plus the three added tests: 3 failed, 7 existing passed. Patched full suite: 737 passed, 3 existing skipped, across 58 files.
  • All workspace builds, lint, API documentation generation and changed-file Prettier checks passed.
  • Real headless Chromium 151, Firefox 153 and WebKit 26.5 each ran eight synthetic API cases: 3 incorrect results on original main, 0 after the fix, including normal language/quality-ordering controls. Original main was compiled from its pinned TypeScript source; the patched side used the built public API.
  • An additional 64 empty-item insertion cases had 48 mismatches on original main and none after the fix. Published 0.7.0 was independently checked to omit empty locale strings; its older quality-ordering behavior is not treated as identical to main.

The evidence is limited to local synthetic language-list outputs. No downstream production failure or affected deployed service has been established.

AI assisted source/test preparation and a separate static review; the results above were verified by local execution.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

acceptedLanguages returns empty locale strings for whitespace-only entries on main

1 participant