Open piotrekwitkowski opened 5 years ago
cc @gauntface
Is this an issue with the demos, the content or is this a content request?
Content Request / Content Issue
If a bug with the demo What was the expected outcome vs actual outcome and what browsers are affect, please include versions.
I am opening (or refocusing) page on notification click as described here.
If the service worker is registered at the domain root, the Jeff Posnick's method does the trick:
const urlToOpen = new URL('/page', self.location.origin).href;`
However, if the service worker is scoped, the new URL will omit the subdirectory completly, because its second argument is base
new URL
base
new URL('/page', 'https://domain.com/sub/').href; => https://domain.com/page
It can be solved by gluing self.registration.scope already available in the service worker and page:
self.registration.scope
page
self.registration.scope + 'page' => https://domain.com/sub/page
Can such information be useful in the context of the web push book? Should I issue a PR?
Thanks for great tutorials @gauntface!
cc @gauntface
Type of Issue
Content Request / Content Issue
Details....
I am opening (or refocusing) page on notification click as described here.
If the service worker is registered at the domain root, the Jeff Posnick's method does the trick:
However, if the service worker is scoped, the
new URL
will omit the subdirectory completly, because its second argument isbase
It can be solved by gluing
self.registration.scope
already available in the service worker andpage
:Can such information be useful in the context of the web push book? Should I issue a PR?
Thanks for great tutorials @gauntface!