Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support serving images under s3 subdirectories, Fix to make /fit-in/ work; Fix for VipsJpeg: Invalid SOS error plus several other critical fixes. #130

Closed
wants to merge 13 commits into from
Closed
Next Next commit
Support serving images under s3 subdirectories
  • Loading branch information
Arpee Ong committed Jul 24, 2019
commit 98c94a4fe9c186d465818881b112c6d508c26df2
13 changes: 8 additions & 5 deletions source/image-handler/image-request.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
const ThumborMapping = require('./thumbor-mapping');

class ImageRequest {

/**
* Initializer function for creating a new image request, used by the image
* handler to perform image modifications.
Expand Down Expand Up @@ -137,8 +137,11 @@ class ImageRequest {
return decoded.key;
} else if (requestType === "Thumbor" || requestType === "Custom") {
// Parse the key from the end of the path
const key = (event["path"]).split("/");
return key[key.length - 1];
//const key = (event["path"]).split("/");

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Delete these two lines? or add comment?

//return key[key.length - 1];

//Arpee: Support serving images under s3 subdirectories
return decodeURIComponent(event["path"].replace(/\/\d+x\d+/,'').substring(1));
} else {
// Return an error for all other conditions
throw ({
Expand All @@ -160,8 +163,8 @@ class ImageRequest {
const path = event["path"];
// ----
const matchDefault = new RegExp(/^(\/?)([0-9a-zA-Z+\/]{4})*(([0-9a-zA-Z+\/]{2}==)|([0-9a-zA-Z+\/]{3}=))?$/);
const matchThumbor = new RegExp(/^(\/?)((fit-in)?|(filters:.+\(.?\))?|(unsafe)?).*(.+jpg|.+png|.+webp|.+tiff|.+jpeg)$/);
const matchCustom = new RegExp(/(\/?)(.*)(jpg|png|webp|tiff|jpeg)/);
const matchThumbor = new RegExp(/^(\/?)((fit-in)?|(filters:.+\(.?\))?|(unsafe)?).*(.+jpg|.+png|.+webp|.+tiff|.+jpeg)$/i);
const matchCustom = new RegExp(/(\/?)(.*)(jpg|png|webp|tiff|jpeg)/i);
const definedEnvironmentVariables = (
(process.env.REWRITE_MATCH_PATTERN !== "") &&
(process.env.REWRITE_SUBSTITUTION !== "") &&
Expand Down