[devdocsgjs/main: 743/1867] Update service worker to more accurately detect 'internal' url's
- From: Andy Holmes <andyholmes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [devdocsgjs/main: 743/1867] Update service worker to more accurately detect 'internal' url's
- Date: Fri, 19 Nov 2021 23:47:27 +0000 (UTC)
commit ad8cd233d732df6f7ea341b8377d41f07661c9ab
Author: Jasper van Merle <jaspervmerle gmail com>
Date: Tue Aug 6 12:59:27 2019 +0200
Update service worker to more accurately detect 'internal' url's
views/service-worker.js.erb | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
---
diff --git a/views/service-worker.js.erb b/views/service-worker.js.erb
index e64e6355..9e32ef89 100644
--- a/views/service-worker.js.erb
+++ b/views/service-worker.js.erb
@@ -48,7 +48,10 @@ self.addEventListener('fetch', event => {
<%# Attempt to return the index page from the cache if the user is visiting a url like
devdocs.io/offline or devdocs.io/javascript/global_objects/array/find %>
<%# The index page will make sure the correct documentation or a proper offline page is shown %>
- if (url.origin === location.origin && !url.pathname.replace(/~([0-9.])+/, '').includes('.')) {
+ const pathname = url.pathname;
+ const filename = pathname.substr(1 + pathname.lastIndexOf('/')).split(/\#|\?/g)[0];
+
+ if (url.origin === location.origin && !filename.includes('.')) {
const cachedIndex = await caches.match('/');
if (cachedIndex) return cachedIndex;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]