Skip to content

Commit

Permalink
Merge pull request #18 from sinankeskin/master
Browse files Browse the repository at this point in the history
Fix cannot read property 'indexOf' of null error
  • Loading branch information
Marten Schilstra authored Apr 28, 2021
2 parents 383f616 + 4d6344e commit 7094edd
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion service-worker/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ self.addEventListener('fetch', (event) => {
let request = event.request;
let url = new URL(request.url);
let isGETRequest = request.method === 'GET';
let isHTMLRequest = request.headers.get('accept').indexOf('text/html') !== -1;
let acceptHeader = request.headers !== null ? request.headers.get('accept') : null;
let isHTMLRequest = acceptHeader !== null ? acceptHeader.indexOf('text/html') !== -1 : true;
let isLocal = url.origin === location.origin;
let scopeExcluded = urlMatchesAnyPattern(request.url, INDEX_EXCLUDE_SCOPE);
let scopeIncluded = !INDEX_INCLUDE_SCOPE.length || urlMatchesAnyPattern(request.url, INDEX_INCLUDE_SCOPE);
Expand Down

0 comments on commit 7094edd

Please # to comment.