From 1a0d8e25011640e84673a67959c969c33ac84ee5 Mon Sep 17 00:00:00 2001 From: Rosa Gutierrez Date: Fri, 23 Jan 2026 13:52:28 +0100 Subject: [PATCH] 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 --- app/views/pwa/service_worker.js | 2 +- test/lib/web_push/persistent_request_test.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/pwa/service_worker.js b/app/views/pwa/service_worker.js index 1216c550d..91903e735 100644 --- a/app/views/pwa/service_worker.js +++ b/app/views/pwa/service_worker.js @@ -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)) }) diff --git a/test/lib/web_push/persistent_request_test.rb b/test/lib/web_push/persistent_request_test.rb index 2cf8a6c7c..649e27b75 100644 --- a/test/lib/web_push/persistent_request_test.rb +++ b/test/lib/web_push/persistent_request_test.rb @@ -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,