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) => {
|
self.addEventListener('fetch', (event) => {
|
||||||
if (event.request.method === 'POST' && event.request.url.endsWith('/accounts/add/')) {
|
const url = new URL(event.request.url);
|
||||||
event.respondWith(
|
if (url.pathname === '/share-target/') {
|
||||||
(async () => {
|
const text = url.searchParams.get('text');
|
||||||
const formData = await event.request.formData();
|
const redirectUrl = `/accounts/add?shared_text=${encodeURIComponent(text)}`;
|
||||||
const text = formData.get('text') || '';
|
event.respondWith(Response.redirect(redirectUrl, 303));
|
||||||
return Response.redirect(`/accounts/add?shared_text=${encodeURIComponent(text)}`, 303);
|
|
||||||
})()
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
@ -26,7 +26,7 @@
|
|||||||
"background_color": "#ffffff",
|
"background_color": "#ffffff",
|
||||||
"display": "standalone",
|
"display": "standalone",
|
||||||
"share_target": {
|
"share_target": {
|
||||||
"action": "/accounts/add/",
|
"action": "/share-target/",
|
||||||
"method": "GET",
|
"method": "GET",
|
||||||
"params": {
|
"params": {
|
||||||
"title": "title",
|
"title": "title",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user