mirror of
https://github.com/discourse/discourse.git
synced 2025-01-31 16:01:02 +08:00
Merge pull request #5832 from featheredtoast/safari-no-serviceworkers
Fix: Safari failing to download backups from email links
This commit is contained in:
commit
0e284e54f3
|
@ -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