Created
June 6, 2019 16:07
-
-
Save MattIPv4/1371cac248d763ab93fc5c13056cef96 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
addEventListener('fetch', event => { | |
event.respondWith(fetchAndApply(event.request)) | |
}) | |
async function fetchAndApply(request) { | |
const requestURL = new URL(request.url) | |
if(!requestURL.pathname.startsWith('/ajax/libs')) { | |
requestURL.pathname = '/ajax/libs' + requestURL.pathname | |
const newResponse = await fetch(requestURL, request) | |
if(newResponse.status == 200) return newResponse | |
} | |
return fetch(request) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment