-
Notifications
You must be signed in to change notification settings - Fork 388
add option for each stripPrefix to have own replacePrefix #142
Conversation
…ths to another directory (i.e. server sends foo/file.txt for requests to bar/file.txt, as well as caching bar/other-file.txt)
We found a Contributor License Agreement for you (the sender of this pull request) and all commit authors, but as best as we can tell these commits were authored by someone else. If that's the case, please add them to this pull request and have them confirm that they're okay with these commits being contributed to Google. If we're mistaken and you did author these commits, just reply here to confirm. |
Hey @SignpostMarv! Please confirm you're ok with the change and maybe we can get these both in at once. Also, any suggestions? |
Thinking something like this: var stripPrefixAsObj = {
"replaceThis": "withThat",
"replaceThisOtherThing": "withThatOtherThing"
};
var relativeUrl = fileAndSizeAndHash.file.replace(
new RegExp('/^(' + Object.keys(stripPrefixAsObj).map(escapeRegExp).join('|') + ')'),
function (match) {
return stripPrefixAsObj[match];
}
); |
Nice! I like it. I'll update my PR in a few. |
Sorry, I've been offline for a bit and am catching up on things at the moment. Just so I understand the scope of what's in this PR, it seems like it includes everything from @SignpostMarv's #138, correct? So I can close that PR and just provide feedback on this? |
|
Thanks for the original contribution, @cdbattags. I've merged #138, and if you want to reconcile the conflicts in your current PR and ensure all linting/tests pass, I'll be happy to merge yours. |
@@ -0,0 +1,3 @@ | |||
[*] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd prefer not to check this in.
Hi all! Sorry for the delay! Yeah, @jeffposnick, with the |
Okay, if you're happy with the implementation in #138 and feel like it covers the same ground, I'm happy to close this and will tag a new |
depends on #138 from @SignpostMarv
Building off of #138, I wanted to add functionality for each each stripPrefix to have it's own replacePrefix. The use case would be having multiple "modules" that each have their own "public" directory that are all globbed into the sw.js file.
Format for stripPrefix if you'd like the functionality is as follows:
or