Socket
Socket
Sign inDemoInstall

workbox-routing

Package Overview
Dependencies
Maintainers
4
Versions
95
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

workbox-routing - npm Package Compare versions

Comparing version 5.0.0 to 5.1.0

2

_version.js
"use strict";
// @ts-ignore
try {
self['workbox:routing:5.0.0'] && _();
self['workbox:routing:5.1.0'] && _();
}
catch (e) { }

@@ -6,3 +6,3 @@ this.workbox = this.workbox || {};

try {
self['workbox:routing:5.0.0'] && _();
self['workbox:routing:5.1.0'] && _();
} catch (e) {}

@@ -486,3 +486,3 @@

let {
const {
params,

@@ -496,3 +496,3 @@ route

let handler = route && route.handler;
let debugMessages = [];
const debugMessages = [];

@@ -618,3 +618,3 @@ {

let params;
let matchResult = route.match({
const matchResult = route.match({
url,

@@ -829,3 +829,3 @@ request,

if (valueToCheck.match(new RegExp(`${wildcards}`))) {
if (new RegExp(`${wildcards}`).exec(valueToCheck)) {
logger_js.logger.debug(`The '$capture' parameter contains an Express-style wildcard ` + `character (${wildcards}). Strings are now always interpreted as ` + `exact matches; use a RegExp for partial or wildcard matches.`);

@@ -832,0 +832,0 @@ }

@@ -1,2 +0,2 @@

this.workbox=this.workbox||{},this.workbox.routing=function(t,e){"use strict";try{self["workbox:routing:5.0.0"]&&_()}catch(t){}const s="GET",r=t=>t&&"object"==typeof t?t:{handle:t};class n{constructor(t,e,n=s){this.handler=r(e),this.match=t,this.method=n}}class o extends n{constructor(t,e,s){super(({url:e})=>{const s=t.exec(e.href);if(s&&(e.origin===location.origin||0===s.index))return s.slice(1)},e,s)}}class i{constructor(){this.t=new Map}get routes(){return this.t}addFetchListener(){self.addEventListener("fetch",t=>{const{request:e}=t,s=this.handleRequest({request:e,event:t});s&&t.respondWith(s)})}addCacheListener(){self.addEventListener("message",t=>{if(t.data&&"CACHE_URLS"===t.data.type){const{payload:e}=t.data,s=Promise.all(e.urlsToCache.map(t=>{"string"==typeof t&&(t=[t]);const e=new Request(...t);return this.handleRequest({request:e})}));t.waitUntil(s),t.ports&&t.ports[0]&&s.then(()=>t.ports[0].postMessage(!0))}})}handleRequest({request:t,event:e}){const s=new URL(t.url,location.href);if(!s.protocol.startsWith("http"))return;let r,{params:n,route:o}=this.findMatchingRoute({url:s,request:t,event:e}),i=o&&o.handler;if(!i&&this.s&&(i=this.s),i){try{r=i.handle({url:s,request:t,event:e,params:n})}catch(t){r=Promise.reject(t)}return r instanceof Promise&&this.o&&(r=r.catch(r=>this.o.handle({url:s,request:t,event:e}))),r}}findMatchingRoute({url:t,request:e,event:s}){const r=this.t.get(e.method)||[];for(const n of r){let r,o=n.match({url:t,request:e,event:s});if(o)return r=o,Array.isArray(o)&&0===o.length?r=void 0:o.constructor===Object&&0===Object.keys(o).length?r=void 0:"boolean"==typeof o&&(r=void 0),{route:n,params:r}}return{}}setDefaultHandler(t){this.s=r(t)}setCatchHandler(t){this.o=r(t)}registerRoute(t){this.t.has(t.method)||this.t.set(t.method,[]),this.t.get(t.method).push(t)}unregisterRoute(t){if(!this.t.has(t.method))throw new e.WorkboxError("unregister-route-but-not-found-with-method",{method:t.method});const s=this.t.get(t.method).indexOf(t);if(!(s>-1))throw new e.WorkboxError("unregister-route-route-not-registered");this.t.get(t.method).splice(s,1)}}let u;const c=()=>(u||((u=new i).addFetchListener(),u.addCacheListener()),u);return t.NavigationRoute=class extends n{constructor(t,{allowlist:e=[/./],denylist:s=[]}={}){super(t=>this.i(t),t),this.u=e,this.h=s}i({url:t,request:e}){if(e&&"navigate"!==e.mode)return!1;const s=t.pathname+t.search;for(const t of this.h)if(t.test(s))return!1;return!!this.u.some(t=>t.test(s))}},t.RegExpRoute=o,t.Route=n,t.Router=i,t.registerRoute=function(t,s,r){let i;if("string"==typeof t){const e=new URL(t,location.href);i=new n(({url:t})=>t.href===e.href,s,r)}else if(t instanceof RegExp)i=new o(t,s,r);else if("function"==typeof t)i=new n(t,s,r);else{if(!(t instanceof n))throw new e.WorkboxError("unsupported-route-type",{moduleName:"workbox-routing",funcName:"registerRoute",paramName:"capture"});i=t}return c().registerRoute(i),i},t.setCatchHandler=function(t){c().setCatchHandler(t)},t.setDefaultHandler=function(t){c().setDefaultHandler(t)},t}({},workbox.core._private);
this.workbox=this.workbox||{},this.workbox.routing=function(t,e){"use strict";try{self["workbox:routing:5.1.0"]&&_()}catch(t){}const s=t=>t&&"object"==typeof t?t:{handle:t};class r{constructor(t,e,r="GET"){this.handler=s(e),this.match=t,this.method=r}}class n extends r{constructor(t,e,s){super(({url:e})=>{const s=t.exec(e.href);if(s&&(e.origin===location.origin||0===s.index))return s.slice(1)},e,s)}}class o{constructor(){this.t=new Map}get routes(){return this.t}addFetchListener(){self.addEventListener("fetch",t=>{const{request:e}=t,s=this.handleRequest({request:e,event:t});s&&t.respondWith(s)})}addCacheListener(){self.addEventListener("message",t=>{if(t.data&&"CACHE_URLS"===t.data.type){const{payload:e}=t.data,s=Promise.all(e.urlsToCache.map(t=>{"string"==typeof t&&(t=[t]);const e=new Request(...t);return this.handleRequest({request:e})}));t.waitUntil(s),t.ports&&t.ports[0]&&s.then(()=>t.ports[0].postMessage(!0))}})}handleRequest({request:t,event:e}){const s=new URL(t.url,location.href);if(!s.protocol.startsWith("http"))return;const{params:r,route:n}=this.findMatchingRoute({url:s,request:t,event:e});let o,i=n&&n.handler;if(!i&&this.s&&(i=this.s),i){try{o=i.handle({url:s,request:t,event:e,params:r})}catch(t){o=Promise.reject(t)}return o instanceof Promise&&this.o&&(o=o.catch(r=>this.o.handle({url:s,request:t,event:e}))),o}}findMatchingRoute({url:t,request:e,event:s}){const r=this.t.get(e.method)||[];for(const n of r){let r;const o=n.match({url:t,request:e,event:s});if(o)return r=o,(Array.isArray(o)&&0===o.length||o.constructor===Object&&0===Object.keys(o).length||"boolean"==typeof o)&&(r=void 0),{route:n,params:r}}return{}}setDefaultHandler(t){this.s=s(t)}setCatchHandler(t){this.o=s(t)}registerRoute(t){this.t.has(t.method)||this.t.set(t.method,[]),this.t.get(t.method).push(t)}unregisterRoute(t){if(!this.t.has(t.method))throw new e.WorkboxError("unregister-route-but-not-found-with-method",{method:t.method});const s=this.t.get(t.method).indexOf(t);if(!(s>-1))throw new e.WorkboxError("unregister-route-route-not-registered");this.t.get(t.method).splice(s,1)}}let i;const u=()=>(i||(i=new o,i.addFetchListener(),i.addCacheListener()),i);return t.NavigationRoute=class extends r{constructor(t,{allowlist:e=[/./],denylist:s=[]}={}){super(t=>this.i(t),t),this.u=e,this.h=s}i({url:t,request:e}){if(e&&"navigate"!==e.mode)return!1;const s=t.pathname+t.search;for(const t of this.h)if(t.test(s))return!1;return!!this.u.some(t=>t.test(s))}},t.RegExpRoute=n,t.Route=r,t.Router=o,t.registerRoute=function(t,s,o){let i;if("string"==typeof t){const e=new URL(t,location.href);i=new r(({url:t})=>t.href===e.href,s,o)}else if(t instanceof RegExp)i=new n(t,s,o);else if("function"==typeof t)i=new r(t,s,o);else{if(!(t instanceof r))throw new e.WorkboxError("unsupported-route-type",{moduleName:"workbox-routing",funcName:"registerRoute",paramName:"capture"});i=t}return u().registerRoute(i),i},t.setCatchHandler=function(t){u().setCatchHandler(t)},t.setDefaultHandler=function(t){u().setDefaultHandler(t)},t}({},workbox.core._private);
//# sourceMappingURL=workbox-routing.prod.js.map

@@ -24,4 +24,4 @@ import { Route } from './Route.js';

declare class NavigationRoute extends Route {
private _allowlist;
private _denylist;
private readonly _allowlist;
private readonly _denylist;
/**

@@ -28,0 +28,0 @@ * If both `denylist` and `allowlist` are provided, the `denylist` will

{
"name": "workbox-routing",
"version": "5.0.0",
"version": "5.1.0",
"license": "MIT",

@@ -31,5 +31,5 @@ "author": "Google's Web DevRel Team",

"dependencies": {
"workbox-core": "^5.0.0"
"workbox-core": "^5.1.0"
},
"gitHead": "571ffded1872309a305f108a99a5a36982fde342"
"gitHead": "2a6b84b892b5c404671b898e926bf37b65d261da"
}

@@ -51,3 +51,3 @@ /*

const wildcards = '[*:?+]';
if (valueToCheck.match(new RegExp(`${wildcards}`))) {
if ((new RegExp(`${wildcards}`)).exec(valueToCheck)) {
logger.debug(`The '$capture' parameter contains an Express-style wildcard ` +

@@ -94,3 +94,2 @@ `character (${wildcards}). Strings are now always interpreted as ` +

}
;
export { registerRoute };

@@ -23,3 +23,3 @@ import { Route } from './Route.js';

declare class Router {
private _routes;
private readonly _routes;
private _defaultHandler?;

@@ -36,3 +36,3 @@ private _catchHandler?;

*/
readonly routes: Map<HTTPMethod, Route[]>;
get routes(): Map<HTTPMethod, Route[]>;
/**

@@ -39,0 +39,0 @@ * Adds a fetch event listener to respond to events when a route matches

@@ -137,5 +137,5 @@ /*

}
let { params, route } = this.findMatchingRoute({ url, request, event });
const { params, route } = this.findMatchingRoute({ url, request, event });
let handler = route && route.handler;
let debugMessages = [];
const debugMessages = [];
if (process.env.NODE_ENV !== 'production') {

@@ -240,3 +240,3 @@ if (handler) {

let params;
let matchResult = route.match({ url, request, event });
const matchResult = route.match({ url, request, event });
if (matchResult) {

@@ -243,0 +243,0 @@ // See https://github.com/GoogleChrome/workbox/issues/2079

@@ -23,3 +23,2 @@ /*

}
;
export { setCatchHandler };

@@ -26,3 +26,2 @@ /*

}
;
export { setDefaultHandler };
// @ts-ignore
try{self['workbox:routing:5.0.0']&&_()}catch(e){}
try{self['workbox:routing:5.1.0']&&_()}catch(e){}

@@ -16,4 +16,4 @@ /*

export interface NavigationRouteMatchOptions {
allowlist?: RegExp[],
denylist?: RegExp[],
allowlist?: RegExp[];
denylist?: RegExp[];
}

@@ -37,4 +37,4 @@

class NavigationRoute extends Route {
private _allowlist: RegExp[];
private _denylist: RegExp[];
private readonly _allowlist: RegExp[];
private readonly _denylist: RegExp[];

@@ -41,0 +41,0 @@ /**

@@ -63,3 +63,3 @@ /*

const wildcards = '[*:?+]';
if (valueToCheck.match(new RegExp(`${wildcards}`))) {
if ((new RegExp(`${wildcards}`)).exec(valueToCheck)) {
logger.debug(

@@ -109,4 +109,4 @@ `The '$capture' parameter contains an Express-style wildcard ` +

return route;
};
}
export {registerRoute}

@@ -26,3 +26,3 @@ /*

payload: {
urlsToCache: RequestArgs[],
urlsToCache: RequestArgs[];
};

@@ -49,3 +49,3 @@ }

class Router {
private _routes: Map<HTTPMethod, Route[]>;
private readonly _routes: Map<HTTPMethod, Route[]>;
private _defaultHandler?: HandlerObject;

@@ -155,4 +155,4 @@ private _catchHandler?: HandlerObject;

handleRequest({request, event}: {
request: Request,
event?: ExtendableEvent,
request: Request;
event?: ExtendableEvent;
}): Promise<Response> | undefined {

@@ -177,6 +177,6 @@ if (process.env.NODE_ENV !== 'production') {

let {params, route} = this.findMatchingRoute({url, request, event});
const {params, route} = this.findMatchingRoute({url, request, event});
let handler = route && route.handler;
let debugMessages = [];
const debugMessages = [];
if (process.env.NODE_ENV !== 'production') {

@@ -272,6 +272,6 @@ if (handler) {

findMatchingRoute({url, request, event}: {
url: URL,
request: Request,
event?: ExtendableEvent
}): {route?: Route, params?: HandlerCallbackOptions['params']} {
url: URL;
request: Request;
event?: ExtendableEvent;
}): {route?: Route; params?: HandlerCallbackOptions['params']} {
if (process.env.NODE_ENV !== 'production') {

@@ -295,3 +295,3 @@ assert!.isInstance(url, URL, {

let params;
let matchResult = route.match({url, request, event});
const matchResult = route.match({url, request, event});
if (matchResult) {

@@ -298,0 +298,0 @@ // See https://github.com/GoogleChrome/workbox/issues/2079

@@ -25,4 +25,4 @@ /*

defaultRouter.setCatchHandler(handler);
};
}
export {setCatchHandler}

@@ -29,4 +29,4 @@ /*

defaultRouter.setDefaultHandler(handler);
};
}
export {setDefaultHandler}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc