Skip to content

Commit 1e3f42c

Browse files
Doug Toppindougtoppin
authored andcommitted
Remove unicode changes from backend, fix unicode support in demo-ui
1 parent b2e0871 commit 1e3f42c

File tree

3 files changed

+13
-6
lines changed

3 files changed

+13
-6
lines changed

source/demo-ui/scripts.js

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,13 @@ function importOriginalImage() {
1818
// Assemble the image request
1919
const request = {
2020
bucket: bucketName,
21-
key: encodeURIComponent(keyName)
21+
key: keyName
2222
}
2323
const strRequest = JSON.stringify(request);
24-
const encRequest = btoa(strRequest);
24+
const encRequest = btoa(encodeURIComponent(strRequest).replace(/%([0-9A-F]{2})/g, function(match, p1) {
25+
return String.fromCharCode(parseInt(p1, 16))
26+
}));
27+
2528
// Import the image data into the element
2629
$(`#img-original`)
2730
.attr(`src`, `${appVariables.apiEndpoint}/${encRequest}`)
@@ -77,14 +80,18 @@ function getPreviewImage() {
7780
// Set up the request body
7881
const request = {
7982
bucket: bucketName,
80-
key: encodeURIComponent(keyName),
83+
key: keyName,
8184
edits: _edits
8285
}
8386
if (Object.keys(request.edits).length === 0) { delete request.edits }
8487
console.log(request);
8588
// Setup encoded request
8689
const str = JSON.stringify(request);
87-
const enc = btoa(str);
90+
91+
const enc = btoa(encodeURIComponent(str).replace(/%([0-9A-F]{2})/g, function(match, p1) {
92+
return String.fromCharCode(parseInt(p1, 16))
93+
}));
94+
8895
// Fill the preview image
8996
$(`#img-preview`).attr(`src`, `${appVariables.apiEndpoint}/${enc}`);
9097
// Fill the request body field

source/image-handler/image-handler.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -443,7 +443,7 @@ export class ImageHandler {
443443
alpha: string,
444444
sourceImageMetadata: sharp.Metadata
445445
): Promise<Buffer> {
446-
const params = { Bucket: bucket, Key: decodeURIComponent(key) };
446+
const params = { Bucket: bucket, Key: key };
447447
try {
448448
const { width, height } = sourceImageMetadata;
449449
const overlayImage: S3.GetObjectOutput = await this.s3Client.getObject(params).promise();

source/image-handler/image-request.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ export class ImageRequest {
269269
if (requestType === RequestTypes.DEFAULT) {
270270
// Decode the image request and return the image key
271271
const { key } = this.decodeRequest(event);
272-
return decodeURIComponent(key);
272+
return key;
273273
}
274274

275275
if (requestType === RequestTypes.THUMBOR || requestType === RequestTypes.CUSTOM) {

0 commit comments

Comments
 (0)