mirror of
https://github.com/discourse/discourse.git
synced 2025-01-18 17:02:45 +08:00
Fix: Safari failing to download backups from email links
disable service workers on safari bypass serviceworker network if this is a URL with a token param
This commit is contained in:
parent
a041a42645
commit
82a95164e9
|
@ -6,9 +6,10 @@ export default {
|
|||
(location.hostname === "localhost");
|
||||
|
||||
const isSupported= isSecured && ('serviceWorker' in navigator);
|
||||
const isSafari = /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
|
||||
|
||||
if (isSupported) {
|
||||
if (Discourse.ServiceWorkerURL) {
|
||||
if (Discourse.ServiceWorkerURL && !isSafari) {
|
||||
navigator.serviceWorker
|
||||
.register(`${Discourse.BaseUri}/${Discourse.ServiceWorkerURL}`)
|
||||
.catch(error => {
|
||||
|
|
|
@ -65,6 +65,10 @@ self.addEventListener('activate', function(event) {
|
|||
});
|
||||
|
||||
self.addEventListener('fetch', function(event) {
|
||||
// Bypass service workers if this is a url with a token param
|
||||
if(/\?.*token/i.test(event.request.url)) {
|
||||
return;
|
||||
}
|
||||
// We only want to call event.respondWith() if this is a navigation request
|
||||
// for an HTML page.
|
||||
// request.mode of 'navigate' is unfortunately not supported in Chrome
|
||||
|
|
Loading…
Reference in New Issue
Block a user