diff options
author | Timothy Flynn <trflynn89@pm.me> | 2021-09-05 18:31:22 -0400 |
---|---|---|
committer | Linus Groh <mail@linusgroh.de> | 2021-09-06 15:24:27 +0100 |
commit | 14086c69e79720328115d55720e75c0382fd328f (patch) | |
tree | bfe07d66883c042837750c2185b2583db9331d7d /Userland/Libraries/LibJS/Runtime/Intl | |
parent | 40ea6592828e28c9a562adb546f1713eb751b6bf (diff) | |
download | serenity-14086c69e79720328115d55720e75c0382fd328f.zip |
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.
Diffstat (limited to 'Userland/Libraries/LibJS/Runtime/Intl')
-rw-r--r-- | Userland/Libraries/LibJS/Runtime/Intl/AbstractOperations.cpp | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/Userland/Libraries/LibJS/Runtime/Intl/AbstractOperations.cpp b/Userland/Libraries/LibJS/Runtime/Intl/AbstractOperations.cpp index 39f8b51229..1f2d7a0774 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/AbstractOperations.cpp +++ b/Userland/Libraries/LibJS/Runtime/Intl/AbstractOperations.cpp @@ -274,11 +274,9 @@ static MatcherResult lookup_matcher(Vector<String> const& requested_locales) auto locale_id = Unicode::parse_unicode_locale_id(locale); 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. - 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). 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) { // 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. - result.extensions = move(extensions); + result.extensions.extend(move(extensions)); } // iii. Return result. |