Skip to content

Commit 6ef34b5

Browse files
authored
fix(smithy-client): use uppercase for percent encodings (#2500)
1 parent 122c139 commit 6ef34b5

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import { extendedEncodeURIComponent } from "./extended-encode-uri-component";
2+
3+
describe(extendedEncodeURIComponent.name, () => {
4+
const encodedValues: [string, string][] = [
5+
["!", "%21"],
6+
["'", "%27"],
7+
["(", "%28"],
8+
[")", "%29"],
9+
["*", "%2A"],
10+
];
11+
12+
const verify = (table: [string, string][]) => {
13+
it.each(table)(`encodes %s as %s`, (input, output) => {
14+
expect(extendedEncodeURIComponent(input)).toStrictEqual(output);
15+
});
16+
};
17+
18+
verify(encodedValues);
19+
verify([encodedValues.reduce((acc, [input, output]) => [acc[0].concat(input), acc[1].concat(output)], ["", ""])]);
20+
});

Diff for: packages/smithy-client/src/extended-encode-uri-component.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@
44
*/
55
export function extendedEncodeURIComponent(str: string): string {
66
return encodeURIComponent(str).replace(/[!'()*]/g, function (c) {
7-
return "%" + c.charCodeAt(0).toString(16);
7+
return "%" + c.charCodeAt(0).toString(16).toUpperCase();
88
});
99
}

0 commit comments

Comments
 (0)