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

Support for registerRoute(<string>) #1028

Merged
merged 6 commits into from
Nov 10, 2017
Merged

Support for registerRoute(<string>) #1028

merged 6 commits into from
Nov 10, 2017

Conversation

jeffposnick
Copy link
Contributor

@coveralls
Copy link

Coverage Status

Changes Unknown when pulling f6b5037 on string-routes-in-v3 into ** on v3**.

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.

Mostly LGTM, just some of the logic I think can be simplified and the Error thrown on express style stuff should be a warning message, not an error.

assert,
cacheNames,
logger,
} from 'workbox-core/_private.mjs';

Choose a reason for hiding this comment

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

This will need to be changed to:

import {WorkboxError} from 'workbox-core/_private/WorkboxError.mjs';
import {assert} from 'workbox-core/_private/assert.mjs';
...
});
}

// We want to only prohibit these characters in the pathname portion of

Choose a reason for hiding this comment

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

Can you change this to "We want to check if express style characters are in the pathname only."

// See https://github.com/pillarjs/path-to-regexp#parameters
const wildcards = '[*:?+]';
if (valueToCheck.match(new RegExp(`${wildcards}`))) {
throw new WorkboxError('invalid-wildcards', {
Copy link

@gauntface gauntface Nov 10, 2017

Choose a reason for hiding this comment

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

I really think this should be a warning and not an error.

Also worth adding a TODO to remove this in v4

https://stackoverflow.com/questions/5649730/what-characters-can-one-use-in-a-url


const matchCallback = ({url}) => {
// If we have a path-only capture pattern...
if (capture.startsWith('/')) {

Choose a reason for hiding this comment

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

This if statement feels error prone.

Wouldn't this have the same result:

// If capture is full URL, new URL will do nothing, if it's '/' it'll have same origin
return (url.href === new URL(capture, location).href);

You could nest a debug message to call out "the pathname matches but the origin is different so if you intended a match, please use the full URL".

@jeffposnick
Copy link
Contributor Author

PTAL. It should have pr-bot properly configured now as well.

@coveralls
Copy link

Coverage Status

Changes Unknown when pulling b8bf6ba on string-routes-in-v3 into ** on v3**.

@coveralls
Copy link

Coverage Status

Changes Unknown when pulling 99f6770 on string-routes-in-v3 into ** on v3**.

@workbox-pr-bot
Copy link
Collaborator

PR-Bot Size Plugin

Changed File Sizes

File Before After Change GZipped
packages/workbox-routing/build/workbox-routing.prod.js 2.64 KB 2.74 KB +4% 1.24 KB

New Files

No new files have been added.

All File Sizes

View Table
File Before After Change GZipped
packages/workbox-background-sync/build/workbox-background-sync.prod.js 2.74 KB 2.74 KB 0% 1.27 KB
packages/workbox-build/build/index.js 16.52 KB 16.52 KB 0% 5.04 KB
packages/workbox-cache-expiration/build/workbox-cache-expiration.prod.js 2.53 KB 2.53 KB 0% 1.07 KB
packages/workbox-cli/build/app.js 3.93 KB 3.93 KB 0% 1.48 KB
packages/workbox-cli/build/bin.js 2.53 KB 2.53 KB 0% 1.07 KB
packages/workbox-core/build/workbox-core.prod.js 5.34 KB 5.34 KB 0% 2.39 KB
packages/workbox-google-analytics/build/workbox-google-analytics.prod.js 1.87 KB 1.87 KB 0% 917 B
packages/workbox-precaching/build/workbox-precaching.prod.js 4.00 KB 4.00 KB 0% 1.74 KB
packages/workbox-routing/build/workbox-routing.prod.js 2.64 KB 2.74 KB +4% 1.24 KB
packages/workbox-runtime-caching/build/workbox-runtime-caching.prod.js 2.96 KB 2.96 KB 0% 1.01 KB
packages/workbox-sw/build/workbox-sw.js 1.34 KB 1.34 KB 0% 738 B
packages/workbox-webpack-plugin/build/index.js 9.59 KB 9.59 KB 0% 2.86 KB

Workbox Aggregate Size Plugin

☠️ WARNING ☠️

We are using 126% of our max size budget.

Total Size: 18.46KB
Percentage of Size Used: 126%

Gzipped: 7.99KB

@coveralls
Copy link

Coverage Status

Changes Unknown when pulling 99f6770 on string-routes-in-v3 into ** on v3**.

Copy link
Member

@addyosmani addyosmani left a comment

Choose a reason for hiding this comment

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

LGTM. Over to Matt for a confirm on review comments being addressed.

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.

LGTM - Thanks Jeff.

@gauntface gauntface merged commit 7e0e1ed into v3 Nov 10, 2017
@gauntface gauntface deleted the string-routes-in-v3 branch November 10, 2017 22:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
5 participants