Stick with %20, don't replace with +

This commit is contained in:
Justin Spahr-Summers 2025-01-16 11:24:39 +00:00
commit 5a6823a0db
No known key found for this signature in database
2 changed files with 2 additions and 2 deletions

View file

@ -34,7 +34,7 @@ describe("UriTemplate", () => {
it("should encode reserved characters", () => {
const template = new UriTemplate("{var}");
expect(template.expand({ var: "value with spaces" })).toBe(
"value+with+spaces",
"value%20with%20spaces",
);
});
});

View file

@ -125,7 +125,7 @@ export class UriTemplate {
if (operator === "+" || operator === "#") {
return encodeURI(value);
}
return encodeURIComponent(value).replace(/%20/g, "+");
return encodeURIComponent(value);
}
private expandPart(