from werkzeug.datastructures import LanguageAccept
from werkzeug.http import parse_accept_header
a = parse_accept_header("en-US,fr-FR", LanguageAccept)
assert a.best == "en-US" # fails, it returns fr-FR
I expected the order to be preserved.
RFC 3282 describes desired behavior for Accept-Language: "If no Q values are given, the language-ranges are given in priority order, with the leftmost language-range being the most preferred language; this is an extension to the HTTP/1.1 rules, but matches current practice."
Looking at the source code, the Accept class is reverse-sorting the input list by specificity, then quality, then name; I think it should not sort by name and instead should preserve the given order.
I expected the order to be preserved.
RFC 3282 describes desired behavior for Accept-Language: "If no Q values are given, the language-ranges are given in priority order, with the leftmost language-range being the most preferred language; this is an extension to the HTTP/1.1 rules, but matches current practice."
Looking at the source code, the Accept class is reverse-sorting the input list by specificity, then quality, then name; I think it should not sort by name and instead should preserve the given order.