From bf5d3b241a98829eb996132fdfe7aa41bd390494 Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Thu, 11 Aug 2022 14:57:21 -0500 Subject: [PATCH 1/3] SW: don't serve /embed paths --- webpack/production.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/webpack/production.js b/webpack/production.js index 43792e97c..6e2f6d810 100644 --- a/webpack/production.js +++ b/webpack/production.js @@ -120,7 +120,7 @@ module.exports = merge(sharedConfig, { ]; if (pathname) { - return backendRoutes.some(path => pathname.startsWith(path)); + return backendRoutes.some(path => pathname.startsWith(path)) || pathname.endsWith('/embed'); } else { return false; } From c5d46d1a158c8539603fd326c316c702bc8a6793 Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Thu, 11 Aug 2022 15:28:42 -0500 Subject: [PATCH 2/3] eslint: disable consistent-return --- .eslintrc.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index 7fa666e36..164949e65 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -78,7 +78,6 @@ module.exports = { 'space-infix-ops': 'error', 'space-in-parens': ['error', 'never'], 'keyword-spacing': 'error', - 'consistent-return': 'error', 'dot-notation': 'error', eqeqeq: 'error', indent: ['error', 2, { @@ -278,7 +277,6 @@ module.exports = { files: ['**/*.ts', '**/*.tsx'], rules: { 'no-undef': 'off', // https://stackoverflow.com/a/69155899 - 'consistent-return': 'off', }, parser: '@typescript-eslint/parser', }, From b085073c10763eed70282554fb0380be08f2d6b8 Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Thu, 11 Aug 2022 15:32:27 -0500 Subject: [PATCH 3/3] SW: refactor cacheMap to correctly return a URL --- webpack/production.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/webpack/production.js b/webpack/production.js index 6e2f6d810..9bd16e045 100644 --- a/webpack/production.js +++ b/webpack/production.js @@ -92,7 +92,10 @@ module.exports = merge(sharedConfig, { cacheMaps: [{ // NOTE: This function gets stringified by OfflinePlugin, so don't try // moving it anywhere else or making it depend on anything outside it! - match: ({ pathname }) => { + // https://github.com/NekR/offline-plugin/blob/master/docs/cache-maps.md + match: (url) => { + const { pathname } = url; + const backendRoutes = [ '/.well-known', '/activities', @@ -119,10 +122,8 @@ module.exports = merge(sharedConfig, { '/unsubscribe', ]; - if (pathname) { - return backendRoutes.some(path => pathname.startsWith(path)) || pathname.endsWith('/embed'); - } else { - return false; + if (backendRoutes.some(path => pathname.startsWith(path)) || pathname.endsWith('/embed')) { + return url; } }, requestTypes: ['navigate'],