File tree Expand file tree Collapse file tree 1 file changed +6
-6
lines changed Expand file tree Collapse file tree 1 file changed +6
-6
lines changed Original file line number Diff line number Diff line change 3131/**
3232 * Parses a cookie string
3333 */
34- export function parseCookie ( str : string ) : Record < string , string > {
35- const obj : Record < string , string > = { } ;
34+ export function parseCookie ( str : string ) : Map < string , string > {
35+ const cookieMap = new Map < string , string > ( ) ;
3636 let index = 0 ;
3737
3838 while ( index < str . length ) {
@@ -56,7 +56,7 @@ export function parseCookie(str: string): Record<string, string> {
5656 const key = str . slice ( index , eqIdx ) . trim ( ) ;
5757
5858 // only assign once
59- if ( undefined === obj [ key ] ) {
59+ if ( undefined === cookieMap . get ( key ) ) {
6060 let val = str . slice ( eqIdx + 1 , endIdx ) . trim ( ) ;
6161
6262 // quoted values
@@ -65,14 +65,14 @@ export function parseCookie(str: string): Record<string, string> {
6565 }
6666
6767 try {
68- obj [ key ] = val . indexOf ( '%' ) !== - 1 ? decodeURIComponent ( val ) : val ;
68+ cookieMap . set ( key , val . indexOf ( '%' ) !== - 1 ? decodeURIComponent ( val ) : val ) ;
6969 } catch ( e ) {
70- obj [ key ] = val ;
70+ cookieMap . set ( key , val ) ;
7171 }
7272 }
7373
7474 index = endIdx + 1 ;
7575 }
7676
77- return obj ;
77+ return cookieMap ;
7878}
You can’t perform that action at this time.
0 commit comments