Skip to content

Commit 18fb16b

Browse files
authored
feat(sw-controller): compare host instead of href for getWindowClient (#2772)
1 parent 5a60243 commit 18fb16b

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

packages/messaging/src/controllers/sw-controller.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -273,13 +273,13 @@ function getNotificationData(
273273
async function getWindowClient(url: string): Promise<WindowClient | null> {
274274
// Use URL to normalize the URL when comparing to windowClients.
275275
// This at least handles whether to include trailing slashes or not
276-
const parsedURL = new URL(url, self.location.href).href;
276+
const parsedURL = new URL(url, self.location.href);
277277

278278
const clientList = await getClientList();
279279

280280
for (const client of clientList) {
281-
const parsedClientUrl = new URL(client.url, self.location.href).href;
282-
if (parsedClientUrl === parsedURL) {
281+
const parsedClientUrl = new URL(client.url, self.location.href);
282+
if (parsedClientUrl.host === parsedURL.host) {
283283
return client;
284284
}
285285
}

0 commit comments

Comments
 (0)