fix: service worker bug
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
kieran 2024-05-13 14:54:03 +01:00
parent 9b99d0e2ea
commit f8f54a4e50
Signed by: Kieran
GPG Key ID: DE71CEB3925BE941
2 changed files with 4 additions and 4 deletions

View File

@ -1,8 +1,8 @@
/// <reference lib="webworker" />
import { hexToBytes } from "@noble/hashes/utils";
import { bech32 } from "@scure/base";
import { encodeTLVEntries, NostrPrefix, TLVEntryType } from "@snort/system/dist/links";
import { NostrLink, tryParseNostrLink } from "@snort/system/dist/nostr-link";
import { encodeTLVEntries, NostrPrefix, TLVEntryType } from "@snort/system/src/links";
import { CacheableResponsePlugin } from "workbox-cacheable-response";
import { clientsClaim } from "workbox-core";
import { ExpirationPlugin } from "workbox-expiration";
@ -19,7 +19,7 @@ clientsClaim();
// cache everything in current domain /assets because precache doesn't seem to include everything
registerRoute(
({ url }) => url.origin === window.location.origin && url.pathname.startsWith("/assets"),
({ url }) => url.origin === self.location.origin && url.pathname.startsWith("/assets"),
new StaleWhileRevalidate({
cacheName: "assets-cache",
plugins: [
@ -250,7 +250,7 @@ function replaceMentions(content: string, profiles: Array<CompactProfile>) {
.map(i => {
if (MentionNostrEntityRegex.test(i)) {
const link = tryParseNostrLink(i);
if (link?.type === NostrPrefix.PublicKey || link?.type === NostrPrefix.Profile) {
if (link && (link.type === NostrPrefix.PublicKey || link.type === NostrPrefix.Profile)) {
const px = profiles.find(a => a.pubkey === link.id);
return `@${displayNameOrDefault(px ?? { pubkey: link.id })}`;
}

View File

@ -2,7 +2,7 @@ import * as utils from "@noble/curves/abstract/utils";
import { bech32 } from "@scure/base";
import { HexKey } from "./nostr";
export const enum NostrPrefix {
export enum NostrPrefix {
PublicKey = "npub",
PrivateKey = "nsec",
Note = "note",