2016-03-25 20:03:49 +00:00
|
|
|
self.addEventListener('fetch', function (event) {
|
2018-09-28 23:17:00 +00:00
|
|
|
const requestUrl = new URL(event.request.url)
|
2015-12-20 20:02:08 +00:00
|
|
|
|
|
|
|
if (requestUrl.pathname === '/echo' &&
|
2016-03-25 20:03:49 +00:00
|
|
|
event.request.headers.has('X-Mock-Response')) {
|
2018-09-28 23:17:00 +00:00
|
|
|
const mockResponse = new Response('Hello from serviceWorker!')
|
2016-03-25 20:03:49 +00:00
|
|
|
event.respondWith(mockResponse)
|
2015-12-20 20:02:08 +00:00
|
|
|
}
|
2016-03-25 20:03:49 +00:00
|
|
|
})
|