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

fix: properly evaluate process.env.AUTO_WEBP #195

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion source/image-handler/image-request.js
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,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 && event.headers.Accept.includes('image/webp')) {
return 'webp';
} else if (this.requestType === 'Default') {
Expand Down
6 changes: 3 additions & 3 deletions source/image-handler/test/test-image-request.js
Original file line number Diff line number Diff line change
Expand Up @@ -689,7 +689,7 @@ describe('getOutputFormat()', function () {
it(`Should pass if it returns "webp" for an accepts header which includes webp`, function () {
// Arrange
process.env = {
AUTO_WEBP: true
AUTO_WEBP: "Yes"
};
const event = {
headers: {
Expand All @@ -707,7 +707,7 @@ describe('getOutputFormat()', function () {
it(`Should pass if it returns null for an accepts header which does not include webp`, function () {
// Arrange
process.env = {
AUTO_WEBP: true
AUTO_WEBP: "Yes"
};
const event = {
headers: {
Expand All @@ -725,7 +725,7 @@ describe('getOutputFormat()', function () {
it(`Should pass if it returns null when AUTO_WEBP is disabled with accepts header including webp`, function () {
// Arrange
process.env = {
AUTO_WEBP: false
AUTO_WEBP: "No"
};
const event = {
headers: {
Expand Down