@@ -19,7 +19,7 @@ type CookieProperties = {
1919 sameSite ?: "None" | "Lax" | "Strict" ;
2020}
2121
22- const cookiePropertyKeys : ( keyof CookieProperties ) [ ] = [ "domain" , "expires" , "path" , "secure" , "httpOnly" , "maxAge" , "sameSite" ] ;
22+ const cookiePropertyKeys = [ "domain" , "expires" , "path" , "secure" , "httpOnly" , "maxAge" , "sameSite" ] as const ;
2323
2424
2525function serializeCookieOptions ( options ?: CookieOptions ) {
@@ -28,9 +28,8 @@ function serializeCookieOptions(options?: CookieOptions) {
2828 }
2929 let memo = "" ;
3030 for ( const key in options ) {
31- if ( ! options . hasOwnProperty ( key ) || ! cookiePropertyKeys . includes ( key as keyof CookieProperties ) ) {
31+ if ( ! cookiePropertyKeys . includes ( key as keyof CookieProperties ) )
3232 continue ;
33- }
3433
3534 const value = options [ key as keyof CookieProperties ] ;
3635 memo +=
@@ -88,7 +87,7 @@ export const cookieStorage: StorageWithOptions<CookieOptions> = addClearMethod({
8887 if ( eventOrRequest . responseHeaders ) // Check if we really got a pageEvent
8988 {
9089 const responseHeaders = eventOrRequest . responseHeaders as Headers ;
91- result += responseHeaders . get ( "Set-Cookie" ) ?. split ( "," ) . map ( cookie => ! cookie . match ( ` \\w*\\s*=\\s*[^;]+` ) ) . join ( ";" ) ?? "" ;
90+ result += responseHeaders . get ( "Set-Cookie" ) ?. split ( "," ) . map ( cookie => ! cookie . match ( / \\ w * \\ s * = \\ s * [ ^ ; ] + / ) ) . join ( ";" ) ?? "" ;
9291 }
9392 return `${ result } ;${ request ?. headers ?. get ( "Cookie" ) ?? "" } ` ; // because first cookie will be preferred we don't have to worry about duplicates
9493 }
@@ -111,9 +110,8 @@ export const cookieStorage: StorageWithOptions<CookieOptions> = addClearMethod({
111110 : ( key : string , value : string , options ?: CookieOptions ) => {
112111 document . cookie = `${ key } =${ value } ${ serializeCookieOptions ( options ) } ` ;
113112 } ,
114- getItem : ( key : string , options ?: CookieOptions ) => {
115- return deserializeCookieOptions ( cookieStorage . _read ( options ) , key )
116- } ,
113+ getItem : ( key : string , options ?: CookieOptions ) =>
114+ deserializeCookieOptions ( cookieStorage . _read ( options ) , key ) ,
117115 setItem : ( key : string , value : string , options ?: CookieOptions ) => {
118116 const oldValue = isServer ? cookieStorage . getItem ( key , options ) : null ;
119117 cookieStorage . _write ( key , value , options ) ;
0 commit comments