From 6ece7fa137221dad483c0b9ee9160081a8dc0686 Mon Sep 17 00:00:00 2001 From: liamcottle Date: Thu, 13 Feb 2025 19:17:09 +1300 Subject: [PATCH] don't include url fragment in client url check --- src/public/service-worker.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/public/service-worker.js b/src/public/service-worker.js index 16802a7..b2bd6e9 100644 --- a/src/public/service-worker.js +++ b/src/public/service-worker.js @@ -26,13 +26,14 @@ self.addEventListener('notificationclick', function(event) { }); -const findClientForUrl = function(url) { +const findClientForUrl = function(urlToOpen) { return self.clients.matchAll({ type: "window", includeUncontrolled: true, }).then(function (clientList) { return clientList.find(function(client) { - return client.url.endsWith(url); + const [ clientUrlWithoutFragment ] = client.url.split("#"); + return clientUrlWithoutFragment.endsWith(urlToOpen); }); }); };