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

Prevent attempting to precache empty URLs which causes SW install failure #271

Merged
merged 1 commit into from
Apr 6, 2020

Conversation

westonruter
Copy link
Collaborator

Fixes #270.

At the moment when attempting to precache an empty URL such as via:

add_action( 'wp_front_service_worker', function ( WP_Service_Worker_Scripts $service_worker ) {
	$service_worker->precaching_routes()->register( '' );
} );

The result is the service worker failing to install at all.

For this reason, this PR emits a _doing_it_wrong if the $url is empty or cannot be parsed. This allows the service worker to still be installed, while the incorrect usage will appear in the error log.

Aside: It may be better to also emit the incorrect usage via console.warn() so that the issue is more easily seen.

@felixarntz felixarntz merged commit 3c5e181 into master Apr 6, 2020
@felixarntz felixarntz deleted the fix/block-precaching-empty-urls branch April 6, 2020 14:45
@westonruter westonruter added this to the 0.5 milestone May 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants