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

v2: Warn on usage of Express-style wildcard characters #1049

Merged
merged 2 commits into from
Nov 16, 2017

Conversation

jeffposnick
Copy link
Contributor

R: @addyosmani @gauntface

Fixes #1011

Using warn() vs. a lower log level is up for negotiation.

I was planning on writing a test to make sure that logHelper.warn() was getting called, but then I realized we had issues in v2 with stubbing out code that is internal to the bundle. I can't find any examples of stubbing out logHelper methods, but if someone knows of some prior art, I'll copy it and add in some tests.

const valueToCheck = capture.startsWith('http') ?
new URL(capture, location).pathname :
capture;
const match = valueToCheck.match(new RegExp(`${wildcards}`));

Choose a reason for hiding this comment

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

Nit: Change match to possibleExpressString

logHelper.warn({
message: `registerRoute() was called with a string containing an ` +
`Express-style wildcard character. While this is currently ` +
`supported, it will no longer be treated as a wildcard match in ` +

Choose a reason for hiding this comment

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

Simplify the message here.

Suggestion:
registerRoute() was called with a string containing an express-style wild card character. In the next version of Workbox express style routes won't be supported by default, instead strings will have to be exact matches. Please switch to regulare expressions.

Copy link

@gauntface gauntface left a comment

Choose a reason for hiding this comment

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

Added suggestions but LGTM

@jeffposnick jeffposnick merged commit 16b51e9 into master Nov 16, 2017
@jeffposnick jeffposnick deleted the warn-on-wildcard-capture branch November 16, 2017 21:23
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