Skip to content

Commit 251dd57

Browse files
author
Chase Coalwell
authored
fix: consistently encode query (#935)
1 parent 3dfe61b commit 251dd57

File tree

3 files changed

+5
-7
lines changed

3 files changed

+5
-7
lines changed

Diff for: packages/querystring-builder/src/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { QueryParameterBag } from "@aws-sdk/types";
2-
import { escapeUri, escapeUriPath } from "@aws-sdk/util-uri-escape";
2+
import { escapeUri } from "@aws-sdk/util-uri-escape";
33

44
export function buildQueryString(query: QueryParameterBag): string {
55
const parts: string[] = [];

Diff for: packages/signature-v4/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
"@aws-sdk/is-array-buffer": "^1.0.0-alpha.2",
2222
"@aws-sdk/types": "^1.0.0-alpha.4",
2323
"@aws-sdk/util-hex-encoding": "^1.0.0-alpha.2",
24+
"@aws-sdk/util-uri-escape": "^1.0.0-alpha.2",
2425
"tslib": "^1.8.0"
2526
},
2627
"devDependencies": {

Diff for: packages/signature-v4/src/getCanonicalQuery.ts

+3-6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { SIGNATURE_HEADER } from "./constants";
22
import { HttpRequest } from "@aws-sdk/types";
3+
import { escapeUri } from "@aws-sdk/util-uri-escape";
34

45
/**
56
* @internal
@@ -15,18 +16,14 @@ export function getCanonicalQuery({ query = {} }: HttpRequest): string {
1516
keys.push(key);
1617
const value = query[key];
1718
if (typeof value === "string") {
18-
serialized[key] = `${encodeURIComponent(key)}=${encodeURIComponent(
19-
value
20-
)}`;
19+
serialized[key] = `${escapeUri(key)}=${escapeUri(value)}`;
2120
} else if (Array.isArray(value)) {
2221
serialized[key] = value
2322
.slice(0)
2423
.sort()
2524
.reduce(
2625
(encoded: Array<string>, value: string) =>
27-
encoded.concat([
28-
`${encodeURIComponent(key)}=${encodeURIComponent(value)}`
29-
]),
26+
encoded.concat([`${escapeUri(key)}=${escapeUri(value)}`]),
3027
[]
3128
)
3229
.join("&");

0 commit comments

Comments
 (0)