Skip to content

Commit

Permalink
Undo = loop
Browse files Browse the repository at this point in the history
  • Loading branch information
blakeembrey committed Oct 2, 2024
1 parent eca9f8f commit 5e581c2
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,14 +102,19 @@ function parse(str, options) {
var index = 0;

while (index < str.length) {
var endIdx = str.indexOf(';', index);
if (endIdx === -1) endIdx = str.length;
var eqIdx = str.indexOf('=', index);

// no more cookie pairs
if (eqIdx === -1) {
break;
}

var eqIdx = index;
while (eqIdx < endIdx && str.charCodeAt(eqIdx) !== 0x3D /* = */) eqIdx++;
var endIdx = str.indexOf(';', index);

if (eqIdx === endIdx) {
index = endIdx + 1;
if (endIdx === -1) {
endIdx = str.length;
} else if (eqIdx > endIdx) {
index = str.lastIndexOf(';', eqIdx) + 1;
continue;
}

Expand Down

0 comments on commit 5e581c2

Please sign in to comment.