Skip to content

Commit

Permalink
bugfix: Fix AUTO_WEBP handling.
Browse files Browse the repository at this point in the history
  • Loading branch information
mik3y committed Jul 12, 2020
1 parent 6aae888 commit 30ac339
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@
* Removed the additional `custom-resource` lambda.
* Use `yarn`.
* Use `eslint` and `prettier`.
* Add hermetic build using Docker (`make build/serverless-image-handler.zip`)
* Add hermetic build using Docker (`make release`)
* Bugfix: Fixed handling of `AUTO_WEBP` env flag.
2 changes: 1 addition & 1 deletion image-request.js
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ class ImageRequest {
* @param {Object} event - The request body.
*/
getOutputFormat(event) {
const autoWebP = process.env.AUTO_WEBP;
const autoWebP = process.env.AUTO_WEBP == "Yes";
if (
autoWebP &&
event.headers.Accept &&
Expand Down
6 changes: 3 additions & 3 deletions test/test-image-request.js
Original file line number Diff line number Diff line change
Expand Up @@ -754,7 +754,7 @@ describe("getOutputFormat()", () => {
it('Should pass if it returns "webp" for an accepts header which includes webp', () => {
// Arrange
process.env = {
AUTO_WEBP: true,
AUTO_WEBP: "Yes",
};
const event = {
headers: {
Expand All @@ -773,7 +773,7 @@ describe("getOutputFormat()", () => {
it("Should pass if it returns null for an accepts header which does not include webp", () => {
// Arrange
process.env = {
AUTO_WEBP: true,
AUTO_WEBP: "Yes",
};
const event = {
headers: {
Expand All @@ -792,7 +792,7 @@ describe("getOutputFormat()", () => {
it("Should pass if it returns null when AUTO_WEBP is disabled with accepts header including webp", () => {
// Arrange
process.env = {
AUTO_WEBP: false,
AUTO_WEBP: "No",
};
const event = {
headers: {
Expand Down

0 comments on commit 30ac339

Please sign in to comment.