From 33576669d371245f0c0c6cf30a6950244e5d58e4 Mon Sep 17 00:00:00 2001 From: Blake Embrey Date: Mon, 7 Oct 2024 15:48:44 -0700 Subject: [PATCH 1/2] Remove quote parsing from package --- src/index.ts | 8 -------- 1 file changed, 8 deletions(-) diff --git a/src/index.ts b/src/index.ts index 4e12462..07b9fc3 100644 --- a/src/index.ts +++ b/src/index.ts @@ -124,14 +124,6 @@ export function parse( let valStartIdx = startIndex(str, eqIdx + 1, endIdx); let valEndIdx = endIndex(str, endIdx, valStartIdx); - if ( - str.charCodeAt(valStartIdx) === 0x22 /* " */ && - str.charCodeAt(valEndIdx - 1) === 0x22 /* " */ - ) { - valStartIdx++; - valEndIdx--; - } - const value = dec(str.slice(valStartIdx, valEndIdx)); obj[key] = value; } From 661b48db6ff81e4f0a0391c397f00ef42a5a8d02 Mon Sep 17 00:00:00 2001 From: Blake Embrey Date: Tue, 8 Oct 2024 13:50:25 -0700 Subject: [PATCH 2/2] Update tests --- src/parse.spec.ts | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/src/parse.spec.ts b/src/parse.spec.ts index 224aa3d..f1546f4 100644 --- a/src/parse.spec.ts +++ b/src/parse.spec.ts @@ -25,24 +25,19 @@ describe("cookie.parse(str)", function () { it("should URL-decode values", function () { expect(cookie.parse('foo="bar=123456789&name=Magic+Mouse"')).toEqual({ - foo: "bar=123456789&name=Magic+Mouse", + foo: '"bar=123456789&name=Magic+Mouse"', }); expect(cookie.parse("email=%20%22%2c%3b%2f")).toEqual({ email: ' ",;/' }); }); - it("should parse quoted values", function () { - expect(cookie.parse('foo="bar"')).toEqual({ foo: "bar" }); - expect(cookie.parse('foo=" a b c "')).toEqual({ foo: " a b c " }); - }); - it("should trim whitespace around key and value", function () { - expect(cookie.parse(' foo = "bar" ')).toEqual({ foo: "bar" }); + expect(cookie.parse(' foo = "bar" ')).toEqual({ foo: '"bar"' }); expect(cookie.parse(" foo = bar ; fizz = buzz ")).toEqual({ foo: "bar", fizz: "buzz", }); - expect(cookie.parse(' foo = " a b c " ')).toEqual({ foo: " a b c " }); + expect(cookie.parse(' foo = " a b c " ')).toEqual({ foo: '" a b c "' }); expect(cookie.parse(" = bar ")).toEqual({ "": "bar" }); expect(cookie.parse(" foo = ")).toEqual({ foo: "" }); expect(cookie.parse(" = ")).toEqual({ "": "" });