Exact same-origin path/search/hash compare. No substring matching.
(clientUrl, targetPath)
| 49 | |
| 50 | /** Exact same-origin path/search/hash compare. No substring matching. */ |
| 51 | function clientPathMatches(clientUrl, targetPath) { |
| 52 | try { |
| 53 | const parsed = new URL(clientUrl); |
| 54 | |
| 55 | if (parsed.origin !== self.location.origin) { |
| 56 | return false; |
| 57 | } |
| 58 | |
| 59 | return `${parsed.pathname}${parsed.search}${parsed.hash}` === targetPath; |
| 60 | } catch { |
| 61 | return false; |
| 62 | } |
| 63 | } |
| 64 | |
| 65 | self.addEventListener("push", (event) => { |
| 66 | let payload = { title: "Notification", body: "", url: null }; |