Skip to content
Snippets Groups Projects
Unverified Commit c2c14331 authored by Eugen Rochko's avatar Eugen Rochko Committed by GitHub
Browse files

Fix PWA manifest using `/web` paths (#19421)

parent a43a8237
No related branches found
No related tags found
No related merge requests found
......@@ -60,24 +60,15 @@ registerRoute(
self.addEventListener('install', function(event) {
event.waitUntil(Promise.all([openWebCache(), fetchRoot()]).then(([cache, root]) => cache.put('/', root)));
});
self.addEventListener('activate', function(event) {
event.waitUntil(self.clients.claim());
});
self.addEventListener('fetch', function(event) {
const url = new URL(event.request.url);
if (url.pathname.startsWith('/web/')) {
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') {
if (url.pathname === '/auth/sign_out') {
const asyncResponse = fetch(event.request);
const asyncCache = openWebCache();
......
......@@ -52,7 +52,7 @@ class ManifestSerializer < ActiveModel::Serializer
end
def start_url
'/web/home'
'/home'
end
def scope
......@@ -77,11 +77,11 @@ class ManifestSerializer < ActiveModel::Serializer
[
{
name: 'Compose new post',
url: '/web/publish',
url: '/publish',
},
{
name: 'Notifications',
url: '/web/notifications',
url: '/notifications',
},
]
end
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment