Skip to content

Commit 30ac339

Browse files
committed
bugfix: Fix AUTO_WEBP handling.
Fixes aws-solutions#195 Fixes aws-solutions#200
1 parent 6aae888 commit 30ac339

File tree

3 files changed

+6
-5
lines changed

3 files changed

+6
-5
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,5 @@
88
* Removed the additional `custom-resource` lambda.
99
* Use `yarn`.
1010
* Use `eslint` and `prettier`.
11-
* Add hermetic build using Docker (`make build/serverless-image-handler.zip`)
11+
* Add hermetic build using Docker (`make release`)
12+
* Bugfix: Fixed handling of `AUTO_WEBP` env flag.

image-request.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ class ImageRequest {
313313
* @param {Object} event - The request body.
314314
*/
315315
getOutputFormat(event) {
316-
const autoWebP = process.env.AUTO_WEBP;
316+
const autoWebP = process.env.AUTO_WEBP == "Yes";
317317
if (
318318
autoWebP &&
319319
event.headers.Accept &&

test/test-image-request.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -754,7 +754,7 @@ describe("getOutputFormat()", () => {
754754
it('Should pass if it returns "webp" for an accepts header which includes webp', () => {
755755
// Arrange
756756
process.env = {
757-
AUTO_WEBP: true,
757+
AUTO_WEBP: "Yes",
758758
};
759759
const event = {
760760
headers: {
@@ -773,7 +773,7 @@ describe("getOutputFormat()", () => {
773773
it("Should pass if it returns null for an accepts header which does not include webp", () => {
774774
// Arrange
775775
process.env = {
776-
AUTO_WEBP: true,
776+
AUTO_WEBP: "Yes",
777777
};
778778
const event = {
779779
headers: {
@@ -792,7 +792,7 @@ describe("getOutputFormat()", () => {
792792
it("Should pass if it returns null when AUTO_WEBP is disabled with accepts header including webp", () => {
793793
// Arrange
794794
process.env = {
795-
AUTO_WEBP: false,
795+
AUTO_WEBP: "No",
796796
};
797797
const event = {
798798
headers: {

0 commit comments

Comments
 (0)