Fix PWA manifest using /web paths (#19421)

This commit is contained in:
Eugen Rochko 2022-10-23 14:05:18 +02:00 committed by GitHub
parent a43a823768
commit c2c14331b2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 15 deletions

View file

@ -60,24 +60,15 @@ registerRoute(
self.addEventListener('install', function(event) { self.addEventListener('install', function(event) {
event.waitUntil(Promise.all([openWebCache(), fetchRoot()]).then(([cache, root]) => cache.put('/', root))); event.waitUntil(Promise.all([openWebCache(), fetchRoot()]).then(([cache, root]) => cache.put('/', root)));
}); });
self.addEventListener('activate', function(event) { self.addEventListener('activate', function(event) {
event.waitUntil(self.clients.claim()); event.waitUntil(self.clients.claim());
}); });
self.addEventListener('fetch', function(event) { self.addEventListener('fetch', function(event) {
const url = new URL(event.request.url); const url = new URL(event.request.url);
if (url.pathname.startsWith('/web/')) { if (url.pathname === '/auth/sign_out') {
const asyncResponse = fetchRoot();
const asyncCache = openWebCache();
event.respondWith(asyncResponse.then(
response => {
const clonedResponse = response.clone();
asyncCache.then(cache => cache.put('/', clonedResponse)).catch();
return response;
},
() => asyncCache.then(cache => cache.match('/'))));
} else if (url.pathname === '/auth/sign_out') {
const asyncResponse = fetch(event.request); const asyncResponse = fetch(event.request);
const asyncCache = openWebCache(); const asyncCache = openWebCache();

View file

@ -52,7 +52,7 @@ class ManifestSerializer < ActiveModel::Serializer
end end
def start_url def start_url
'/web/home' '/home'
end end
def scope def scope
@ -77,11 +77,11 @@ class ManifestSerializer < ActiveModel::Serializer
[ [
{ {
name: 'Compose new post', name: 'Compose new post',
url: '/web/publish', url: '/publish',
}, },
{ {
name: 'Notifications', name: 'Notifications',
url: '/web/notifications', url: '/notifications',
}, },
] ]
end end