Comparing version 0.12.14 to 0.13.0
@@ -1,4 +0,4 @@ | ||
let { html, links } = | ||
let { html, links, db, globalDb } = | ||
// @ts-ignore | ||
self.app as { links: { file: string, url: string }[], html: Function } | ||
self.app as { links: { file: string, url: string }[], html: Function, db: any, globalDb: any } | ||
@@ -102,2 +102,3 @@ if (!links) { | ||
for (const r of self.app.routes) { | ||
// @ts-ignore | ||
if (r.file | ||
@@ -148,4 +149,22 @@ && (r.route instanceof RegExp && r.route.test(url.pathname) | ||
let isPost = method === "post" | ||
if (!isPost && !url.pathname.endsWith("/")) return cacheResponse(url.pathname, event) | ||
if (!isPost) { | ||
if (!url.pathname.endsWith("/")) { | ||
return cacheResponse(url.pathname, event) | ||
} | ||
if (url.searchParams.get("login") === "success") { | ||
await globalDb.setLoggedIn(true) | ||
} | ||
let lastUrl: string | undefined | ||
if (url.pathname === "/web/" && (lastUrl = (await db.get("last-url"))?.url)) { | ||
url = new URL(lastUrl) | ||
} else if (url.searchParams.has("pushUrl") || url.searchParams.has("hz")) { | ||
let saveUrl = new URL(url.href) | ||
saveUrl.searchParams.delete("pushUrl") | ||
saveUrl.searchParams.delete("hz") | ||
await db.set("last-url", { url: saveUrl.href }, { sync: false }) | ||
} | ||
} | ||
let handlers = | ||
@@ -180,3 +199,3 @@ <RouteHandler<RouteGetArgs | RoutePostArgs> | null> | ||
if (isHtml(result)) { | ||
if (req.url.includes("hz")) { | ||
if (url.searchParams.has("hz")) { | ||
result = html`<template>${result}</template>` | ||
@@ -374,2 +393,1 @@ } | ||
{ | ||
"name": "@jon49/sw", | ||
"version": "0.12.14", | ||
"version": "0.13.0", | ||
"description": "Packages for MVC service workers.", | ||
@@ -5,0 +5,0 @@ "type": "module", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
36511
1009