Skip to content

Commit 954d411

Browse files
authored
fix(cloudfront-signer): skip extended encoding for query parameters in the base url (#7515)
1 parent 81789d8 commit 954d411

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

packages/cloudfront-signer/src/sign.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -812,7 +812,7 @@ describe("getSignedUrl- when signing a URL with a date range", () => {
812812
});
813813

814814
describe("url component encoding", () => {
815-
it("should use extended encoding for query params in the base URL", () => {
815+
it("should use standard encoding for query params in the base URL", () => {
816816
const url =
817817
"https://d111111abcdef8.cloudfront.net/private-content/private.jpeg?q=!@#$%^&*()&image-description=aws's image&'''&!()=5";
818818
const signedUrl = getSignedUrl({
@@ -823,7 +823,7 @@ describe("url component encoding", () => {
823823
});
824824

825825
const target =
826-
"https://d111111abcdef8.cloudfront.net/private-content/private.jpeg?q=%21%40%23%24%25%5E&%2A%28%29=&image-description=aws%27s%20image&%27%27%27=&%21%28%29=5";
826+
"https://d111111abcdef8.cloudfront.net/private-content/private.jpeg?q=!%40%23%24%25%5E&*()=&image-description=aws's%20image&'''=&!()=5";
827827

828828
expect(signedUrl.slice(0, target.length)).toBe(target);
829829
});

packages/cloudfront-signer/src/sign.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ export function getSignedUrl({
147147
if (url.includes("?")) {
148148
const [hostAndPath, query] = url.split("?");
149149
const params = [...new URLSearchParams(query).entries()]
150-
.map(([key, value]) => `${extendedEncodeURIComponent(key)}=${extendedEncodeURIComponent(value)}`)
150+
.map(([key, value]) => `${encodeURIComponent(key)}=${encodeURIComponent(value)}`)
151151
.join("&");
152152
return `${hostAndPath}?${params}`;
153153
}

0 commit comments

Comments
 (0)