Skip to content

Commit

Permalink
Change cookie parsing
Browse files Browse the repository at this point in the history
Solves #29
  • Loading branch information
eelkevdbos committed Oct 17, 2024
1 parent 7c820fc commit c24f4e0
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,17 @@ export type LanguageDetector<
> = (ctx: T) => null | string | Promise<string | null>

export function newLanguageDetector(opts: LanguageDetectorOptions): LanguageDetector {
return ({ set, request, params, store }) => {
return ({ cookie, request, params, store }) => {
const url = new URL(request.url)

const searchParamValue = url.searchParams.get(opts.searchParamName)
if (searchParamValue) {
return searchParamValue
}

const cookie = set.cookie ? set.cookie[opts.cookieName] : null
if (cookie && cookie.value) {
return cookie.value as string
const _cookie = cookie ? cookie[opts.cookieName] : null
if (_cookie && _cookie.value) {
return _cookie.value as string
}

if (params && opts.pathParamName in params) {
Expand Down

0 comments on commit c24f4e0

Please sign in to comment.