revert(ssr): revert locale stuff
All checks were successful
deploy / deploy (push) Successful in 58s
All checks were successful
deploy / deploy (push) Successful in 58s
This commit is contained in:
parent
cfaca9fb40
commit
cfb7d1f15d
@ -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;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
Loading…
Reference in New Issue
Block a user