File tree Expand file tree Collapse file tree 2 files changed +32
-10
lines changed
Expand file tree Collapse file tree 2 files changed +32
-10
lines changed Original file line number Diff line number Diff line change @@ -3,11 +3,23 @@ import { baseurl } from '../../_config.yml';
33importScripts ( `${ baseurl } /assets/js/data/swconf.js` ) ;
44
55const purge = swconf . purge ;
6+ const interceptor = swconf . interceptor ;
67
78function verifyUrl ( url ) {
8- const requestPath = new URL ( url ) . pathname ;
9+ const requestUrl = new URL ( url ) ;
10+ const requestPath = requestUrl . pathname ;
911
10- for ( const path of swconf . denyPaths ) {
12+ if ( ! requestUrl . protocol . startsWith ( 'http' ) ) {
13+ return false ;
14+ }
15+
16+ for ( const prefix of interceptor . urlPrefixes ) {
17+ if ( requestUrl . href . startsWith ( prefix ) ) {
18+ return false ;
19+ }
20+ }
21+
22+ for ( const path of interceptor . paths ) {
1123 if ( requestPath . startsWith ( path ) ) {
1224 return false ;
1325 }
Original file line number Diff line number Diff line change @@ -22,14 +22,24 @@ const swconf = {
2222 { % endfor % }
2323 ] ,
2424
25- { % - comment - % } The request url with below path will not be cached . { % - endcomment - % }
26- denyPaths : [
27- { % for path in site . pwa . cache . deny_paths % }
28- { % unless path == empty % }
29- '{{ path | relative_url }}' { % - unless forloop . last - % } , { % - endunless - % }
30- { % endunless % }
31- { % endfor % }
32- ] ,
25+ interceptor : {
26+ { % - comment - % } URLs containing the following paths will not be cached . { % - endcomment - % }
27+ paths : [
28+ { % for path in site . pwa . cache . deny_paths % }
29+ { % unless path == empty % }
30+ '{{ path | relative_url }}' { % - unless forloop . last - % } , { % - endunless - % }
31+ { % endunless % }
32+ { % endfor % }
33+ ] ,
34+
35+ { % - comment - % } URLs containing the following prefixes will not be cached . { % - endcomment - % }
36+ urlPrefixes : [
37+ { % if site . analytics . goatcounter . id != nil and site . pageviews . provider == 'goatcounter' % }
38+ 'https://{{ site.analytics.goatcounter.id }}.goatcounter.com/counter/'
39+ { % endif % }
40+ ]
41+ } ,
42+
3343 purge : false
3444 { % else % }
3545 purge: true
You can’t perform that action at this time.
0 commit comments