revert(ssr): revert locale stuff
All checks were successful
deploy / deploy (push) Successful in 58s

This commit is contained in:
Lee 2023-11-06 18:52:03 +00:00
parent cfaca9fb40
commit cfb7d1f15d
3 changed files with 1 additions and 39 deletions

@ -15,15 +15,6 @@ export function middleware(request: NextRequest) {
return NextResponse.redirect(new URL("/search", request.url)); return NextResponse.redirect(new URL("/search", request.url));
} }
} }
const requestHeaders = new Headers(request.headers);
requestHeaders.set("x-url", request.url);
return NextResponse.next({
request: {
// New request headers
headers: requestHeaders,
},
});
} }
export const config = { export const config = {

@ -1,5 +1,3 @@
import { getBrowserLocales } from "./utils";
/** /**
* Checks if the given value is an number. * Checks if the given value is an number.
* *
@ -26,7 +24,7 @@ export function formatNumber(number: any, decimals?: number) {
if (typeof number !== "number") { if (typeof number !== "number") {
return number; return number;
} }
return number.toLocaleString(getBrowserLocales(), { return number.toLocaleString(undefined, {
minimumFractionDigits: decimals, minimumFractionDigits: decimals,
maximumFractionDigits: decimals, maximumFractionDigits: decimals,
}); });

@ -49,30 +49,3 @@ export function getPageFromSearchQuery(
return page; return page;
} }
/**
* Gets the users locales from the browser
*
* @param options the options to use
* @returns the browser locales
*/
export function getBrowserLocales(options = {}) {
const defaultOptions = {
languageCodeOnly: false,
};
const opt = {
...defaultOptions,
...options,
};
const browserLocales =
navigator.languages === undefined
? [navigator.language]
: navigator.languages;
if (!browserLocales) {
return undefined;
}
return browserLocales.map((locale) => {
const trimmedLocale = locale.trim();
return opt.languageCodeOnly ? trimmedLocale.split(/-|_/)[0] : trimmedLocale;
});
}