Skip to content

Commit

Permalink
Changed localeCookeValue to localeCookieValue.
Browse files Browse the repository at this point in the history
  • Loading branch information
muhammedaksam committed May 12, 2024
1 parent 3c178ad commit d5210a9
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { LANG_COOKIE } from "../../constants"
export const createCookieDetection =
<T extends string>(cfg: { availableLanguageTags: readonly T[] }): LanguageDetector<T> =>
(request) => {
const localeCookeValue = request.cookies.get(LANG_COOKIE.name)?.value
if (cfg.availableLanguageTags.includes(localeCookeValue as T)) return localeCookeValue as T
const localeCookieValue = request.cookies.get(LANG_COOKIE.name)?.value
if (cfg.availableLanguageTags.includes(localeCookieValue as T)) return localeCookieValue as T
else return undefined
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export function Middleware<T extends string>(opt: MiddlewareOptions<T>) {
* https://nextjs.org/docs/pages/building-your-application/routing/middleware#setting-headers
*/
return function middleware(request: NextRequest) {
const localeCookeValue = request.cookies.get(LANG_COOKIE.name)?.value
const localeCookieValue = request.cookies.get(LANG_COOKIE.name)?.value
const locale = resolveLanguage(request, sourceLanguageTag, [
opt.strategy.resolveLocale,
createCookieDetection({ availableLanguageTags: availableLanguageTags }),
Expand All @@ -64,7 +64,7 @@ export function Middleware<T extends string>(opt: MiddlewareOptions<T>) {
const localisedURL = opt.strategy.getLocalisedUrl(canonicalPath, locale, false)

const localeCookieMatches =
isAvailableLanguageTag(localeCookeValue) && localeCookeValue === locale
isAvailableLanguageTag(localeCookieValue) && localeCookieValue === locale

const headers = new Headers(request.headers)
headers.set(PARAGLIDE_LANGUAGE_HEADER_NAME, locale)
Expand Down

0 comments on commit d5210a9

Please sign in to comment.