mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 19:37:36 +00:00
LibJS: Only remove Unicode locale extensions during the LookupMatcher AO
This was one of the first AOs used for Intl, and I misinterpreted the spec. Rather than removing all extensions, we must only remove Unicode locale extensions. Also use LocaleID::to_string() here instead of the heavier canonical string method, because the locale is already canonical.
This commit is contained in:
parent
40ea659282
commit
14086c69e7
1 changed files with 3 additions and 5 deletions
|
@ -274,11 +274,9 @@ static MatcherResult lookup_matcher(Vector<String> const& requested_locales)
|
||||||
auto locale_id = Unicode::parse_unicode_locale_id(locale);
|
auto locale_id = Unicode::parse_unicode_locale_id(locale);
|
||||||
VERIFY(locale_id.has_value());
|
VERIFY(locale_id.has_value());
|
||||||
|
|
||||||
auto extensions = move(locale_id->extensions);
|
|
||||||
locale_id->private_use_extensions.clear();
|
|
||||||
|
|
||||||
// a. Let noExtensionsLocale be the String value that is locale with any Unicode locale extension sequences removed.
|
// a. Let noExtensionsLocale be the String value that is locale with any Unicode locale extension sequences removed.
|
||||||
auto no_extensions_locale = JS::Intl::canonicalize_unicode_locale_id(*locale_id);
|
auto extensions = locale_id->remove_extension_type<Unicode::LocaleExtension>();
|
||||||
|
auto no_extensions_locale = locale_id->to_string();
|
||||||
|
|
||||||
// b. Let availableLocale be BestAvailableLocale(availableLocales, noExtensionsLocale).
|
// b. Let availableLocale be BestAvailableLocale(availableLocales, noExtensionsLocale).
|
||||||
auto available_locale = best_available_locale(no_extensions_locale);
|
auto available_locale = best_available_locale(no_extensions_locale);
|
||||||
|
@ -292,7 +290,7 @@ static MatcherResult lookup_matcher(Vector<String> const& requested_locales)
|
||||||
if (locale != no_extensions_locale) {
|
if (locale != no_extensions_locale) {
|
||||||
// 1. Let extension be the String value consisting of the substring of the Unicode locale extension sequence within locale.
|
// 1. Let extension be the String value consisting of the substring of the Unicode locale extension sequence within locale.
|
||||||
// 2. Set result.[[extension]] to extension.
|
// 2. Set result.[[extension]] to extension.
|
||||||
result.extensions = move(extensions);
|
result.extensions.extend(move(extensions));
|
||||||
}
|
}
|
||||||
|
|
||||||
// iii. Return result.
|
// iii. Return result.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue