Next.js website for Rocky Mountain Vending company featuring: - Product catalog with Stripe integration - Service areas and parts pages - Admin dashboard with Clerk authentication - SEO optimized pages with JSON-LD structured data Co-authored-by: Cursor <cursoragent@cursor.com>
34 lines
1.2 KiB
Text
34 lines
1.2 KiB
Text
"use strict";
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
exports.BestFitMatcher = BestFitMatcher;
|
|
var utils_1 = require("./utils");
|
|
/**
|
|
* https://tc39.es/ecma402/#sec-bestfitmatcher
|
|
* @param availableLocales
|
|
* @param requestedLocales
|
|
* @param getDefaultLocale
|
|
*/
|
|
function BestFitMatcher(availableLocales, requestedLocales, getDefaultLocale) {
|
|
var foundLocale;
|
|
var extension;
|
|
var noExtensionLocales = [];
|
|
var noExtensionLocaleMap = requestedLocales.reduce(function (all, l) {
|
|
var noExtensionLocale = l.replace(utils_1.UNICODE_EXTENSION_SEQUENCE_REGEX, '');
|
|
noExtensionLocales.push(noExtensionLocale);
|
|
all[noExtensionLocale] = l;
|
|
return all;
|
|
}, {});
|
|
var result = (0, utils_1.findBestMatch)(noExtensionLocales, availableLocales);
|
|
if (result.matchedSupportedLocale && result.matchedDesiredLocale) {
|
|
foundLocale = result.matchedSupportedLocale;
|
|
extension =
|
|
noExtensionLocaleMap[result.matchedDesiredLocale].slice(result.matchedDesiredLocale.length) || undefined;
|
|
}
|
|
if (!foundLocale) {
|
|
return { locale: getDefaultLocale() };
|
|
}
|
|
return {
|
|
locale: foundLocale,
|
|
extension: extension,
|
|
};
|
|
}
|