Comparing version 0.2.7 to 0.2.8
{ | ||
"name": "s3u", | ||
"version": "0.2.7", | ||
"version": "0.2.8", | ||
"description": "S3 URL manipulation helper similar to standard URL class", | ||
@@ -5,0 +5,0 @@ "main": "src/index.js", |
@@ -102,3 +102,4 @@ export class S3Url { | ||
export function encodeS3Key(key: string): string; | ||
export function encodeSpecialUrlChars(string: string): string; | ||
export default S3Url; |
@@ -11,3 +11,3 @@ /* eslint-disable operator-linebreak */ | ||
const S3Url = require('./S3Url'); | ||
const s3KeyUtils = require('./utils/s3key'); | ||
const encode = require('./utils/encode'); | ||
@@ -39,3 +39,3 @@ const s3Parser = new S3Parser({ | ||
S3Provider, | ||
...s3KeyUtils, | ||
...encode, | ||
}; |
@@ -43,5 +43,3 @@ 'use strict'; | ||
if (s3Url.cdn) { | ||
return this.parseUrl({ url: signedUrl }) | ||
.setCdn(true) | ||
.href; | ||
return signedUrl.replace(`.${this.domain}/`, `.cdn.${this.domain}/`); | ||
} | ||
@@ -48,0 +46,0 @@ |
@@ -6,3 +6,7 @@ 'use strict'; | ||
const S3Url = require('./S3Url'); | ||
const { decodeS3Key, encodeS3Key } = require('./utils/s3key'); | ||
const { | ||
decodeS3Key, | ||
encodeS3Key, | ||
encodeSpecialUrlChars, | ||
} = require('./utils/encode'); | ||
const { bufferToHex, hmacSha256, sha256 } = require('./utils/crypto'); | ||
@@ -57,8 +61,4 @@ | ||
url.pathname = url.pathname | ||
.replace(/\+/g, '%20') | ||
// eslint-disable-next-line arrow-body-style | ||
.replace(/[!'()*]/g, (c) => { | ||
return '%' + c.charCodeAt(0).toString(16).toUpperCase(); | ||
}); | ||
url.search = encodeSpecialUrlChars(url.search); | ||
url.pathname = encodeSpecialUrlChars(url.pathname); | ||
@@ -83,5 +83,3 @@ const request = [ | ||
url.searchParams.set('X-Amz-Signature', bufferToHex(await signPromise)); | ||
return url.href; | ||
return `${url.href}&X-Amz-Signature=${bufferToHex(await signPromise)}`; | ||
} | ||
@@ -88,0 +86,0 @@ |
23635
661