Skip to content

Commit

Permalink
fix(cofen): fixed type errors
Browse files Browse the repository at this point in the history
[bump]
  • Loading branch information
DuCanhGH committed Dec 27, 2023
1 parent 2963bed commit 9107baa
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
5 changes: 5 additions & 0 deletions .changeset/few-plums-destroy.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@ducanh2912/next-pwa": patch
---

fix(cofen): fixed type errors
14 changes: 6 additions & 8 deletions packages/next-pwa/src/sw-entry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Workbox } from "workbox-window";

import type { MessageType } from "./sw-entry-worker.js";

declare const __PWA_START_URL__: URL | RequestInfo;
declare const __PWA_START_URL__: string | undefined;
declare const __PWA_SW__: string;
declare const __PWA_ENABLE_REGISTER__: boolean;
declare const __PWA_CACHE_ON_FRONT_END_NAV__: boolean;
Expand Down Expand Up @@ -39,22 +39,20 @@ if (
const cacheOnFrontEndNav = async (
originalUrl?: string | URL | null | undefined
) => {
if (!window.navigator.onLine) {
if (!window.navigator.onLine || !originalUrl) {
return;
}

const url = originalUrl
? originalUrl instanceof URL
const url =
originalUrl instanceof URL
? originalUrl.toString()
: typeof originalUrl === "string"
? originalUrl
: undefined
: undefined;
: undefined;

if (typeof url !== "string") return;

const isStartUrl =
!!__PWA_START_URL__ && originalUrl === __PWA_START_URL__;
const isStartUrl = !!__PWA_START_URL__ && url === __PWA_START_URL__;

if (isStartUrl) {
if (!swEntryWorker) {
Expand Down

0 comments on commit 9107baa

Please sign in to comment.