From 16bd1a39863af0512d310bbac22a44cc7825cb77 Mon Sep 17 00:00:00 2001 From: "Ben Scholzen (DASPRiD)" Date: Mon, 1 Jul 2024 02:49:18 +0200 Subject: [PATCH] fix: skip whitespace after encountering media type separator without parameters --- src/accept.ts | 1 + test/accept.test.ts | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/src/accept.ts b/src/accept.ts index 513f4d3..40c5882 100644 --- a/src/accept.ts +++ b/src/accept.ts @@ -78,6 +78,7 @@ export class AcceptParser { } if (this.readSeparator() === ",") { + this.skipWhitespace(); return [{ ...AcceptParser.default, type, subType }, true]; } diff --git a/test/accept.test.ts b/test/accept.test.ts index bac248b..4861531 100644 --- a/test/accept.test.ts +++ b/test/accept.test.ts @@ -38,6 +38,14 @@ describe("AcceptParser", () => { { type: "application", subType: "xml", parameters: {}, weight: 1, acceptExt: {} }, ], ], + [ + "multiple types with spaces", + "application/json , application/xml", + [ + { type: "application", subType: "json", parameters: {}, weight: 1, acceptExt: {} }, + { type: "application", subType: "xml", parameters: {}, weight: 1, acceptExt: {} }, + ], + ], [ "type with parameter", "application/json ; foo=bar",