rework server-worker
All checks were successful
Build and Publish Docker Image / build-and-push (push) Successful in 4m36s
All checks were successful
Build and Publish Docker Image / build-and-push (push) Successful in 4m36s
This commit is contained in:
parent
d67c4dd94b
commit
7015561136
@ -7,13 +7,10 @@ self.addEventListener('activate', e => {
|
||||
});
|
||||
|
||||
self.addEventListener('fetch', (event) => {
|
||||
if (event.request.method === 'POST' && event.request.url.endsWith('/accounts/add/')) {
|
||||
event.respondWith(
|
||||
(async () => {
|
||||
const formData = await event.request.formData();
|
||||
const text = formData.get('text') || '';
|
||||
return Response.redirect(`/accounts/add?shared_text=${encodeURIComponent(text)}`, 303);
|
||||
})()
|
||||
);
|
||||
const url = new URL(event.request.url);
|
||||
if (url.pathname === '/share-target/') {
|
||||
const text = url.searchParams.get('text');
|
||||
const redirectUrl = `/accounts/add?shared_text=${encodeURIComponent(text)}`;
|
||||
event.respondWith(Response.redirect(redirectUrl, 303));
|
||||
}
|
||||
});
|
@ -26,7 +26,7 @@
|
||||
"background_color": "#ffffff",
|
||||
"display": "standalone",
|
||||
"share_target": {
|
||||
"action": "/accounts/add/",
|
||||
"action": "/share-target/",
|
||||
"method": "GET",
|
||||
"params": {
|
||||
"title": "title",
|
||||
|
Loading…
x
Reference in New Issue
Block a user