Skip to content

Commit 836f014

Browse files
committed
Simplify _encodeURIComponent logic
Signed-off-by: Elijah Zupancic <[email protected]>
1 parent 8a6338e commit 836f014

File tree

1 file changed

+4
-16
lines changed

1 file changed

+4
-16
lines changed

common/etc/nginx/include/s3gateway.js

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -419,7 +419,7 @@ function redirectToS3(r) {
419419
if (isDirectoryListing && r.method === 'GET') {
420420
r.internalRedirect("@s3Listing");
421421
} else if ( provide_index_page == true ) {
422-
r.internalRedirect("@s3");
422+
r.internalRedirect("@s3");
423423
} else if ( !allow_listing && !provide_index_page && uriPath == "/" ) {
424424
r.internalRedirect("@error404");
425425
} else {
@@ -790,21 +790,9 @@ function _padWithLeadingZeros(num, size) {
790790
* @private
791791
*/
792792
function _encodeURIComponent(string) {
793-
var additionalEscapes = [
794-
[/\(/g, '%28'],
795-
[/\)/g, '%29'],
796-
[/\!/g, '%21'],
797-
[/\*/g, '%2A'],
798-
[/\'/g, '%27']
799-
];
800-
801-
var encoded = encodeURIComponent(string);
802-
803-
additionalEscapes.forEach(function (replace) {
804-
encoded = encoded.replace(replace[0], replace[1]);
805-
});
806-
807-
return encoded;
793+
return encodeURIComponent(string)
794+
.replace(/[!*'()]/g, (c) =>
795+
`%${c.charCodeAt(0).toString(16).toUpperCase()}`);
808796
}
809797

810798
/**

0 commit comments

Comments
 (0)