diff --git a/package.json b/package.json index ce09bcde..1e80fe91 100644 --- a/package.json +++ b/package.json @@ -18,7 +18,7 @@ "build": "gulp build", "build:main": "gulp typescript:main", "build:module": "gulp typescript:module", - "build:browser": "gulp rollup", + "build:browser": "gulp build:rollup", "lint": "tslint --project . src/**/*.ts", "prism:mock": "node test/prism.js", "prism:record": "node test/prism.js --record", diff --git a/src/lib/api/transform.spec.ts b/src/lib/api/transform.spec.ts index 1842b799..8561c135 100644 --- a/src/lib/api/transform.spec.ts +++ b/src/lib/api/transform.spec.ts @@ -56,6 +56,7 @@ describe('transform', () => { polaroid: true, flip: false, flop: true, + compress: false, }; const result = transform(url, testConfig); @@ -231,4 +232,38 @@ describe('transform', () => { assert.equal(result, expected); }); }); + + describe('cache', () => { + it('should construct valid parameters', () => { + const testConfig = { + cache: false, + }; + + const result = transform(url, testConfig); + const expected = `${cdnUrl}/cache=false/${url}`; + assert.equal(result, expected); + + const testConfig2 = { + cache: { + expiry: 12345, + }, + }; + + const result2 = transform(url, testConfig2); + const expected2 = `${cdnUrl}/cache=expiry:12345/${url}`; + assert.equal(result2, expected2); + }); + }); + + describe('compress', () => { + it('should construct valid parameters', () => { + const testConfig = { + compress: true, + }; + + const result = transform(url, testConfig); + const expected = `${cdnUrl}/compress/${url}`; + assert.equal(result, expected); + }); + }); }); diff --git a/src/lib/api/transform.ts b/src/lib/api/transform.ts index 8f63b63e..187c5056 100644 --- a/src/lib/api/transform.ts +++ b/src/lib/api/transform.ts @@ -867,12 +867,12 @@ const optionToString = (key: string, values: any): string => { // if we just want to enable feature if (typeof values === 'boolean') { - if (values === undefined) { - return ''; + if (!values && key === 'cache') { + return `${key}=false`; } if (!values) { - return `${key}=false`; + return ''; } return key;