@aws-amplify/core
Version:
Core category of aws-amplify
26 lines (25 loc) • 1.11 kB
JavaScript
;
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
Object.defineProperty(exports, "__esModule", { value: true });
exports.getCanonicalUri = void 0;
/**
* Returns a canonical uri.
*
* @param pathname `pathname` from request url.
* @param uriEscapePath Whether to uri encode the path as part of canonical uri. It's used for S3 only where the
* pathname is already uri encoded, and the signing process is not expected to uri encode it again. Defaults to true.
* @returns URI-encoded version of the absolute path component URL (everything between the host and the question mark
* character (?) that starts the query string parameters). If the absolute path is empty, a forward slash character (/).
*
* @internal
*/
var getCanonicalUri = function (pathname, uriEscapePath) {
if (uriEscapePath === void 0) { uriEscapePath = true; }
return pathname
? uriEscapePath
? encodeURIComponent(pathname).replace(/%2F/g, '/')
: pathname
: '/';
};
exports.getCanonicalUri = getCanonicalUri;