File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -95,17 +95,17 @@ import { LanguageRouter } from "lup-language";
9595
9696// Settings
9797const lupLang = LanguageRouter({
98- defaultLang : 'en',
98+ defaultLanguage : 'en',
9999});
100100
101101export function middleware(request: NextRequest): NextResponse {
102-
102+
103103 // Redirect to correct language
104104 const langInfo = lupLang.nextJsMiddlewareHandler(request);
105105 if(langInfo.redirect || langInfo.cookie){
106106 const langResponse = langInfo.redirect ? NextResponse.redirect(langInfo.redirect, { status: langInfo.redirectResponseCode }) : NextResponse.next();
107107 if(langInfo.cookie){
108- langResponse.cookies.set(langInfo.name, langInfo.cookie.value, langInfo.cookie.options);
108+ langResponse.cookies.set(langInfo.cookie. name, langInfo.cookie.value, langInfo.cookie.options);
109109 }
110110 return langResponse;
111111 }
Original file line number Diff line number Diff line change 11{
22 "name" : " lup-language" ,
3- "version" : " 2.0.0 " ,
3+ "version" : " 2.0.1 " ,
44 "description" : " Node express middleware for detecting requested language" ,
55 "files" : [
66 " lib/**/*"
Original file line number Diff line number Diff line change @@ -108,7 +108,7 @@ export const DEFAULTS: {
108108
109109type NextRequest = Request & {
110110 get cookies ( ) : {
111- get ( name : string ) : { value : string } ;
111+ get ( name : string ) : { value : string } | undefined ;
112112 } ,
113113} ;
114114
@@ -124,9 +124,11 @@ type LanguageNextResponse = {
124124 cookie ?: {
125125 name : string ,
126126 value : string ,
127- expire : number ,
128- domain ?: string ,
129- path ?: string ,
127+ options : {
128+ expire : number ,
129+ domain ?: string ,
130+ path ?: string ,
131+ } ,
130132 } ,
131133
132134 /** Language code that was detected. */
@@ -717,9 +719,11 @@ export const LanguageRouter = (
717719 response . cookie = {
718720 name : cookieName ,
719721 value : lang ,
720- expire : cookieExpire ,
721- domain : cookieDomain ? cookieDomain : undefined ,
722- path : cookiePath ? cookiePath : undefined ,
722+ options : {
723+ expire : cookieExpire ,
724+ domain : cookieDomain ? cookieDomain : undefined ,
725+ path : cookiePath ? cookiePath : undefined ,
726+ }
723727 } ;
724728 }
725729
You can’t perform that action at this time.
0 commit comments