Skip to content

Commit 16bd1a3

Browse files
committed
fix: skip whitespace after encountering media type separator without parameters
1 parent 70cf7b2 commit 16bd1a3

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

src/accept.ts

+1
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ export class AcceptParser {
7878
}
7979

8080
if (this.readSeparator() === ",") {
81+
this.skipWhitespace();
8182
return [{ ...AcceptParser.default, type, subType }, true];
8283
}
8384

test/accept.test.ts

+8
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,14 @@ describe("AcceptParser", () => {
3838
{ type: "application", subType: "xml", parameters: {}, weight: 1, acceptExt: {} },
3939
],
4040
],
41+
[
42+
"multiple types with spaces",
43+
"application/json , application/xml",
44+
[
45+
{ type: "application", subType: "json", parameters: {}, weight: 1, acceptExt: {} },
46+
{ type: "application", subType: "xml", parameters: {}, weight: 1, acceptExt: {} },
47+
],
48+
],
4149
[
4250
"type with parameter",
4351
"application/json ; foo=bar",

0 commit comments

Comments
 (0)