Created by: jeffposnick
R: @Timer @gaearon FYI: @addyosmani
This is a bit more explicit than trying to use a regular expression. It uses the URL
object inside of a block that first checks to see if navigator.serviceWorker
is defined; URL
should always exist in browsers that support service workers.
From testing locally, I saw scenarios in which process.env.PUBLIC_URL
wasn't set at all (which contradicts what @Timer suggested in the issue).
The code in this PR should behave properly regardless of whether it's unset, whether it's set to a local path, or whether it's set to a full URL.
Fixes #2374 (closed)