File tree 2 files changed +32
-10
lines changed
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';
3
3
importScripts ( `${ baseurl } /assets/js/data/swconf.js` ) ;
4
4
5
5
const purge = swconf . purge ;
6
+ const interceptor = swconf . interceptor ;
6
7
7
8
function verifyUrl ( url ) {
8
- const requestPath = new URL ( url ) . pathname ;
9
+ const requestUrl = new URL ( url ) ;
10
+ const requestPath = requestUrl . pathname ;
9
11
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 ) {
11
23
if ( requestPath . startsWith ( path ) ) {
12
24
return false ;
13
25
}
Original file line number Diff line number Diff line change @@ -22,14 +22,24 @@ const swconf = {
22
22
{ % endfor % }
23
23
] ,
24
24
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
+
33
43
purge : false
34
44
{ % else % }
35
45
purge: true
You can’t perform that action at this time.
0 commit comments