Skip to content

fix: ignore invalid accept-language weights#6

Merged
kipcole9 merged 1 commit into
elixir-localize:mainfrom
rubas:fix/accept-language-q-values
Apr 25, 2026
Merged

fix: ignore invalid accept-language weights#6
kipcole9 merged 1 commit into
elixir-localize:mainfrom
rubas:fix/accept-language-q-values

Conversation

@rubas

@rubas rubas commented Apr 24, 2026

Copy link
Copy Markdown
Contributor

Summary

This fixes how Localize.AcceptLanguage treats HTTP q-values.

RFC 9110 defines Accept-Language entries as language ranges with an optional quality weight. Those weights are q-values from 0 to 1, where 0 means "not acceptable" and an omitted q-value means 1.

With this change:

  • fr;q=0,en;q=0.5 selects en, not fr.
  • fr;q=0,en;q=0 returns no match.
  • en;q=2,fr;q=1 selects fr, because q=2 is outside the valid q-value range.
  • malformed q-values are ignored instead of being treated like an omitted q-value.
  • entries without a q-value still default to 1.0.

References:

@rubas rubas force-pushed the fix/accept-language-q-values branch from a2d59fb to 484383a Compare April 24, 2026 09:09
@kipcole9 kipcole9 merged commit 7204952 into elixir-localize:main Apr 25, 2026
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.

2 participants