Skip to content

Commit

Permalink
fix: skip whitespace after encountering media type separator without …
Browse files Browse the repository at this point in the history
…parameters
  • Loading branch information
DASPRiD committed Jul 1, 2024
1 parent 70cf7b2 commit 16bd1a3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/accept.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ export class AcceptParser {
}

if (this.readSeparator() === ",") {
this.skipWhitespace();
return [{ ...AcceptParser.default, type, subType }, true];
}

Expand Down
8 changes: 8 additions & 0 deletions test/accept.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 16bd1a3

Please sign in to comment.