Browse Source

Fix service worker for docs with multiple versions

Jasper van Merle 6 năm trước cách đây
mục cha
commit
eb1429da12
1 tập tin đã thay đổi với 1 bổ sung1 xóa
  1. 1 1
      views/service-worker.js.erb

+ 1 - 1
views/service-worker.js.erb

@@ -48,7 +48,7 @@ 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.includes('.')) {
+      if (url.origin === location.origin && !url.pathname.replace(/~([0-9.])+/, '').includes('.')) {
         const cachedIndex = await caches.match('/');
         if (cachedIndex) return cachedIndex;
       }