Skip to content
This repository has been archived by the owner on Jan 23, 2021. It is now read-only.

Commit

Permalink
Fix issue where toolbox successResponses is stripped (#265)
Browse files Browse the repository at this point in the history
* Fix issue where toolbox successResponses is stripped

Fixed a bug wth successResponses similar to #228

* fixed lint error

* fixed incorrect if block
  • Loading branch information
mahwy authored and jeffposnick committed Mar 22, 2017
1 parent ad24803 commit ac7da0e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/sw-precache.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,10 @@ function stringifyToolboxOptions(options) {
if (options.origin instanceof RegExp) {
str = str.replace(/("origin":)\{\}/, '$1' + options.origin);
}
if (options.successResponses instanceof RegExp) {
str = str.replace(/("successResponses":)\{\}/,
'$1' + options.successResponses);
}
return str;
}

Expand Down
11 changes: 11 additions & 0 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,17 @@ describe('generateRuntimeCaching', function() {
}]);
assert.equal(code, '\ntoolbox.router.get("/*", toolbox.testHandler, {"origin":"http://www.example.com"});');
});

it('should handle successResponses regex', function() {
var code = generateRuntimeCaching([{
urlPattern: '/*',
handler: 'testHandler',
options: {
successResponses: /^200$/
}
}]);
assert.equal(code, '\ntoolbox.router.get("/*", toolbox.testHandler, {"successResponses":/^200$/});');
});
});

describe('cleanResponse', function() {
Expand Down

0 comments on commit ac7da0e

Please sign in to comment.