Skip to content

Commit

Permalink
Fix cookie parsing
Browse files Browse the repository at this point in the history
Solves #8
  • Loading branch information
eelkevdbos committed Oct 17, 2024
1 parent 7c820fc commit 40fec2d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "elysia-i18next",
"version": "4.0.0",
"version": "4.0.2",
"description": "Internationalization (i18n) for Elysia.js via i18next",
"repository": {
"type": "git",
Expand Down
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 40fec2d

Please sign in to comment.