Socket
Socket
Sign inDemoInstall

stream-to-sw

Package Overview
Dependencies
1
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.0.0 to 1.0.1

2

package.json
{
"name": "stream-to-sw",
"version": "1.0.0",
"version": "1.0.1",
"description": "intercept fetch requests with a service worker, but process the response on the main thread",

@@ -5,0 +5,0 @@ "dependencies": {

@@ -27,5 +27,3 @@ const test = require('muggle-test')

const readyPromise = registerStreamToSw('./testWorker.js', async (req, res) => {
const path = req.url.replace(window.origin, '')
switch (path) {
switch (req.path) {
case '/test/penguin': {

@@ -59,2 +57,5 @@ return 'penguin'

}
case '/test/reqPath': {
return req.path
}
case '/test/requestBody': {

@@ -157,2 +158,11 @@ const body = await new window.Response(req.body).text()

test('request.path should be set correctly', async () => {
await readyPromise
const plainPathResponse = await window.fetch('/test/reqPath?param=true#hash')
const plainPath = await plainPathResponse.text()
assert.equal(plainPath, '/test/reqPath', 'path should strip origin, query params, and hash')
})
test('body should be passed into the Req object', async () => {

@@ -159,0 +169,0 @@ await readyPromise

@@ -45,3 +45,3 @@ /* eslint-env serviceworker */

path = path.replace(/#.*$/, '') // trim hash
path = path.replace(/\?.*$/) // trim query params
path = path.replace(/\?.*$/, '') // trim query params
path = path.replace(/\/$/, '') // trim trailing slash if present

@@ -48,0 +48,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc