Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Origin option can be regular expression #47

Merged
merged 2 commits into from
Mar 6, 2017
Merged

Origin option can be regular expression #47

merged 2 commits into from
Mar 6, 2017

Conversation

cyk
Copy link
Contributor

@cyk cyk commented Feb 1, 2017

To enable use of regular expressions in origin options, modify setupRoutes() to use temporary placeholder that is replaced with printPath() parsed origin.

  • options - an object containing options for the route. This options object will be passed to the request handler. The origin option is specific to the router methods, and can be either an exact string or a Regexp against which the origin of the Request must match for the route to be used.

https://github.com/GoogleChrome/sw-toolbox/blob/master/docs/api.md#methods

Example Usage

ENV.serviceWorker = {
  networkFirstURLs: [
    { route: '/(.*)', method: 'get', options: { origin: new RegExp(/myapihost/) } }
  ]
};

@jkleinsc jkleinsc self-requested a review March 6, 2017 16:33
Copy link
Owner

@jkleinsc jkleinsc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cyk Thanks for the PR! Would you mind updating the readme to reflect the change you've made here? (eg change https://github.com/jkleinsc/broccoli-serviceworker/blob/master/README.md#routing-options to indicate origin can be string or regex).

@cyk
Copy link
Contributor Author

cyk commented Mar 6, 2017

@jkleinsc No problem at all. Really appreciate the work you've put into this plug-in. I've added a note RegExp support for the route origin option. Let me know if there is anything else I can do. Thanks.

Copy link
Owner

@jkleinsc jkleinsc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for updating @cyk! I'll merge it in.

@jkleinsc jkleinsc merged commit 1edf77d into jkleinsc:master Mar 6, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants