nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: GoogleChrome/sw-precache
Pull request #228 (2016-12-21 22:35:04)

Fix issue where toolbox origin regex is stripped during json stringify
Fixes https://github.com/GoogleChrome/sw-precache/issues/144

googlebot: Thanks for your pull request.  It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

:memo: **Please visit <https://cla.developers.google.com/> to sign.**

Once you've signed, please reply here (e.g. `I signed it!`) and we'll verify.  Thanks.

---

- If you've already signed a CLA, it's possible we don't have your GitHub username or you're using a different email address.  Check [your existing CLA data](https://cla.developers.google.com/clas) and verify that your [email is set on your git commits](https://help.github.com/articles/setting-your-email-in-git/).
- If you signed the CLA as a corporation, please let us know the company's name.

<!-- need_sender_cla -->
mikestead: I signed it
googlebot: CLAs look good, thanks!

<!-- ok -->
jeffposnick: Thank you, @mikestead!

Patch:
diff --git a/lib/sw-precache.js b/lib/sw-precache.js
index 1d0a27d..0f45a30 100644
--- a/lib/sw-precache.js
+++ b/lib/sw-precache.js
@@ -104,13 +104,22 @@ function generateRuntimeCaching(runtimeCaching) {
         // include its body inline.
         (typeof curr.handler === 'string' ? 'toolbox.' : '') + curr.handler,
         // Default to no options.
-        JSON.stringify(curr.options || {}));
+        stringifyToolboxOptions(curr.options));
     }
 
     return prev + line;
   }, '');
 }
 
+function stringifyToolboxOptions(options) {
+  options = options || {};
+  var str = JSON.stringify(options);
+  if (options.origin instanceof RegExp) {
+    str = str.replace(/("origin":)\{\}/, '$1' + options.origin);
+  }
+  return str;
+}
+
 function generate(params, callback) {
   return new Promise(function(resolve, reject) {
     params = defaults(params || {}, {


Test patch:
diff --git a/test/test.js b/test/test.js
index af060c2..5bb1770 100644
--- a/test/test.js
+++ b/test/test.js
@@ -445,4 +445,26 @@ describe('generateRuntimeCaching', function() {
     }]);
     assert.equal(code, '\ntoolbox.router.get(/test/, toolbox.testHandler, {});');
   });
+
+  it('should handle origin regex', function() {
+    var code = generateRuntimeCaching([{
+      urlPattern: '/*',
+      handler: 'testHandler',
+      options: {
+        origin: /http:\/\/www.example\.com/
+      }
+    }]);
+    assert.equal(code, '\ntoolbox.router.get("/*", toolbox.testHandler, {"origin":/http:\\/\\/www.example\\.com/});');
+  });
+
+  it('should handle origin string', function() {
+    var code = generateRuntimeCaching([{
+      urlPattern: '/*',
+      handler: 'testHandler',
+      options: {
+        origin: 'http://www.example.com'
+      }
+    }]);
+    assert.equal(code, '\ntoolbox.router.get("/*", toolbox.testHandler, {"origin":"http://www.example.com"});');
+  });
 });
Repository: GoogleChrome/sw-precache
Pull request #265 (2017-03-17 22:30:21)

Fix issue where toolbox successResponses is stripped
Fixed a bug wth successResponses similar to #228

googlebot: Thanks for your pull request.  It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

:memo: **Please visit <https://cla.developers.google.com/> to sign.**

Once you've signed, please reply here (e.g. `I signed it!`) and we'll verify.  Thanks.

---

- If you've already signed a CLA, it's possible we don't have your GitHub username or you're using a different email address.  Check [your existing CLA data](https://cla.developers.google.com/clas) and verify that your [email is set on your git commits](https://help.github.com/articles/setting-your-email-in-git/).
- If you signed the CLA as a corporation, please let us know the company's name.

<!-- need_sender_cla -->
mahwy: Signed CLA
googlebot: We found a Contributor License Agreement for you (the sender of this pull request), but were unable to find agreements for the commit author(s).  If you authored these, maybe you used a different email address in the git commits than was used to sign the CLA ([login here](https://cla.developers.google.com/) to double check)?  If these were authored by someone else, then they will need to sign a CLA as well, and confirm that they're okay with these being contributed to Google.

<!-- need_author_cla -->
googlebot: CLAs look good, thanks!

<!-- ok -->
jeffposnick: Thanks, @mahwy!

Patch:
diff --git a/lib/sw-precache.js b/lib/sw-precache.js
index 4a319d8..5d6c7cc 100644
--- a/lib/sw-precache.js
+++ b/lib/sw-precache.js
@@ -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;
 }
 


Test patch:
diff --git a/test/test.js b/test/test.js
index 519d1b3..f766133 100644
--- a/test/test.js
+++ b/test/test.js
@@ -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() {