1eeac4f99b
Follow-up to https://github.com/vercel/next.js/pull/17370 this makes sure the locale detection is case-insensitive.
10 lines
355 B
TypeScript
10 lines
355 B
TypeScript
import { IncomingMessage } from 'http'
|
|
|
|
export function detectLocaleCookie(req: IncomingMessage, locales: string[]) {
|
|
if (req.headers.cookie && req.headers.cookie.includes('NEXT_LOCALE')) {
|
|
const { NEXT_LOCALE } = (req as any).cookies
|
|
return locales.find(
|
|
(locale: string) => NEXT_LOCALE.toLowerCase() === locale.toLowerCase()
|
|
)
|
|
}
|
|
}
|