@@ -59,7 +59,6 @@ const domainValueRegExp =
5959const pathValueRegExp = / ^ [ \u0020 - \u003A \u003D - \u007E ] * $ / ;
6060
6161const __toString = Object . prototype . toString ;
62- const __hasOwnProperty = Object . prototype . hasOwnProperty ;
6362
6463const NullObject = /* @__PURE__ */ ( ( ) => {
6564 const C = function ( ) { } ;
@@ -94,8 +93,8 @@ export interface ParseOptions {
9493export function parse (
9594 str : string ,
9695 options ?: ParseOptions ,
97- ) : Record < string , string > {
98- const obj : Record < string , string > = new NullObject ( ) ;
96+ ) : Record < string , string | undefined > {
97+ const obj : Record < string , string | undefined > = new NullObject ( ) ;
9998 const len = str . length ;
10099 // RFC 6265 sec 4.1.1, RFC 2616 2.2 defines a cookie name consists of one char minimum, plus '='.
101100 if ( len < 2 ) return obj ;
@@ -121,7 +120,7 @@ export function parse(
121120 const key = str . slice ( keyStartIdx , keyEndIdx ) ;
122121
123122 // only assign once
124- if ( ! __hasOwnProperty . call ( obj , key ) ) {
123+ if ( obj [ key ] === undefined ) {
125124 let valStartIdx = startIndex ( str , eqIdx + 1 , endIdx ) ;
126125 let valEndIdx = endIndex ( str , endIdx , valStartIdx ) ;
127126
@@ -134,7 +133,7 @@ export function parse(
134133 }
135134
136135 const value = dec ( str . slice ( valStartIdx , valEndIdx ) ) ;
137- if ( value !== undefined ) obj [ key ] = value ;
136+ obj [ key ] = value ;
138137 }
139138
140139 index = endIdx + 1 ;
@@ -366,7 +365,7 @@ export function serialize(
366365/**
367366 * URL-decode string value. Optimized to skip native call when no %.
368367 */
369- function decode ( str : string ) : string | undefined {
368+ function decode ( str : string ) : string {
370369 if ( str . indexOf ( "%" ) === - 1 ) return str ;
371370
372371 try {
0 commit comments