Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Remove unicode changes from backend, fix unicode support in demo-ui
  • Loading branch information
Doug Toppin authored and dougtoppin committed Feb 7, 2023
commit 1e3f42ce271855114e17812866faecae4df72d49
15 changes: 11 additions & 4 deletions source/demo-ui/scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,13 @@ function importOriginalImage() {
// Assemble the image request
const request = {
bucket: bucketName,
key: encodeURIComponent(keyName)
key: keyName
}
const strRequest = JSON.stringify(request);
const encRequest = btoa(strRequest);
const encRequest = btoa(encodeURIComponent(strRequest).replace(/%([0-9A-F]{2})/g, function(match, p1) {
return String.fromCharCode(parseInt(p1, 16))
}));

// Import the image data into the element
$(`#img-original`)
.attr(`src`, `${appVariables.apiEndpoint}/${encRequest}`)
Expand Down Expand Up @@ -77,14 +80,18 @@ function getPreviewImage() {
// Set up the request body
const request = {
bucket: bucketName,
key: encodeURIComponent(keyName),
key: keyName,
edits: _edits
}
if (Object.keys(request.edits).length === 0) { delete request.edits }
console.log(request);
// Setup encoded request
const str = JSON.stringify(request);
const enc = btoa(str);

const enc = btoa(encodeURIComponent(str).replace(/%([0-9A-F]{2})/g, function(match, p1) {
return String.fromCharCode(parseInt(p1, 16))
}));

// Fill the preview image
$(`#img-preview`).attr(`src`, `${appVariables.apiEndpoint}/${enc}`);
// Fill the request body field
Expand Down
2 changes: 1 addition & 1 deletion source/image-handler/image-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@ export class ImageHandler {
alpha: string,
sourceImageMetadata: sharp.Metadata
): Promise<Buffer> {
const params = { Bucket: bucket, Key: decodeURIComponent(key) };
const params = { Bucket: bucket, Key: key };
try {
const { width, height } = sourceImageMetadata;
const overlayImage: S3.GetObjectOutput = await this.s3Client.getObject(params).promise();
Expand Down
2 changes: 1 addition & 1 deletion source/image-handler/image-request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ export class ImageRequest {
if (requestType === RequestTypes.DEFAULT) {
// Decode the image request and return the image key
const { key } = this.decodeRequest(event);
return decodeURIComponent(key);
return key;
}

if (requestType === RequestTypes.THUMBOR || requestType === RequestTypes.CUSTOM) {
Expand Down