Skip to content

Commit

Permalink
Merge branch 'release-3.6.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
Eduardo Bouças authored and Eduardo Bouças committed Aug 12, 2019
2 parents c73d5de + 134a9b3 commit 8a7af12
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 4 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@ All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](http://keepachangelog.com/).

## [3.6.1] - 2019-08-12

### Fixed

* [#508](https://github.com/dadi/cdn/pull/508): bypass JS processing when no transformation parameters supplied

## [3.6.0] - 2019-05-15

### Changed
Expand Down
39 changes: 37 additions & 2 deletions dadi/lib/handlers/js.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,41 @@ const JSHandler = function (format, req, {
options = {}
} = {}) {
this.legacyURLOverrides = this.getLegacyURLOverrides(req.url)
this.options = options
this.url = url.parse(
this.legacyURLOverrides.url || req.url,
true
)

const mergedOptions = Object.assign({}, this.url.query, this.legacyURLOverrides, options)

// Normalising boolean values (e.g. true vs. 1 vs. '1').
this.options = Object.keys(mergedOptions).reduce((result, key) => {
let value

switch (mergedOptions[key]) {
case 0:
case '0':
case 'false':
value = false

break

case 1:
case '1':
case 'true':
value = true

break

default:
value = mergedOptions[key]
}

result[key] = value

return result
}, {})

this.isExternalUrl = this.url.pathname.indexOf('http://') > 0 || this.url.pathname.indexOf('https://') > 0

this.cache = Cache()
Expand Down Expand Up @@ -82,7 +111,13 @@ JSHandler.prototype.get = function () {
}

return this.storageHandler.get().then(stream => {
return this.transform(stream)
const {compress, transform} = this.options

if (compress === true || transform === true) {
return this.transform(stream)
}

return stream
}).then(stream => {
return this.cache.cacheFile(stream, this.cacheKey, {
ttl: config.get('caching.ttl', this.req.__domain)
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@dadi/cdn",
"version": "3.6.0",
"version": "3.6.1",
"product": "DADI CDN",
"description": "A high performance, just-in-time asset manipulation and delivery layer designed as a modern content distribution solution.",
"scripts": {
Expand Down
3 changes: 2 additions & 1 deletion test/acceptance/recipes.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ describe('Recipes', function () {
'blur': '0',
'strip': '0',
'rotate': '0',
'flip': '0'
'flip': '0',
'transform': '1'
}
}

Expand Down

0 comments on commit 8a7af12

Please sign in to comment.