Fix notification click URL by using correct data property

The web push payload sends the URL in data.url but the service
worker was looking for data.path, resulting in undefined URLs.

Also fix WebPush::Notification test to use url instead of path

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Rosa Gutierrez
2026-01-23 13:52:28 +01:00
parent 155fa2da97
commit 1a0d8e2501
2 changed files with 2 additions and 2 deletions
+1 -1
View File
@@ -25,7 +25,7 @@ async function updateBadgeCount({ data: { badge } }) {
self.addEventListener("notificationclick", (event) => {
event.notification.close()
const url = new URL(event.notification.data.path, self.location.origin).href
const url = new URL(event.notification.data.url, self.location.origin).href
event.waitUntil(openURL(url))
})
+1 -1
View File
@@ -12,7 +12,7 @@ class WebPush::PersistentRequestTest < ActiveSupport::TestCase
notification = WebPush::Notification.new(
title: "Test",
body: "Test notification",
path: "/test",
url: "/test",
badge: 0,
endpoint: ENDPOINT,
endpoint_ip: PUBLIC_TEST_IP,