Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

workbox-routing

Package Overview
Dependencies
Maintainers
6
Versions
96
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 7.0.0 to 7.1.0

176

build/workbox-routing.dev.js

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

// @ts-ignore
try {

@@ -25,3 +26,2 @@ self['workbox:routing:7.0.0'] && _();

*/
const defaultMethod = 'GET';

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

*/
const validMethods = ['DELETE', 'GET', 'HEAD', 'PATCH', 'POST', 'PUT'];

@@ -53,3 +52,2 @@

*/
const normalizeHandler = handler => {

@@ -65,3 +63,2 @@ if (handler && typeof handler === 'object') {

}
return handler;

@@ -77,3 +74,2 @@ } else {

}
return {

@@ -101,3 +97,2 @@ handle: handler

*/
class Route {

@@ -123,3 +118,2 @@ /**

});
if (method) {

@@ -130,6 +124,5 @@ assert_js.assert.isOneOf(method, validMethods, {

}
} // These values are referenced directly by Router so cannot be
}
// These values are referenced directly by Router so cannot be
// altered by minificaton.
this.handler = normalizeHandler(handler);

@@ -144,8 +137,5 @@ this.match = match;

*/
setCatchHandler(handler) {
this.catchHandler = normalizeHandler(handler);
}
}

@@ -175,3 +165,2 @@

*/
class NavigationRoute extends Route {

@@ -220,3 +209,2 @@ /**

}
super(options => this._match(options), handler);

@@ -236,4 +224,2 @@ this._allowlist = allowlist;

*/
_match({

@@ -246,5 +232,3 @@ url,

}
const pathnameAndSearch = url.pathname + url.search;
for (const regExp of this._denylist) {

@@ -255,7 +239,5 @@ if (regExp.test(pathnameAndSearch)) {

}
return false;
}
}
if (this._allowlist.some(regExp => regExp.test(pathnameAndSearch))) {

@@ -265,13 +247,9 @@ {

}
return true;
}
{
logger_js.logger.log(`The navigation route ${pathnameAndSearch} is not ` + `being used, since the URL being navigated to doesn't ` + `match the allowlist.`);
}
return false;
}
}

@@ -297,3 +275,2 @@

*/
class RegExpRoute extends Route {

@@ -322,16 +299,14 @@ /**

}
const match = ({
url
}) => {
const result = regExp.exec(url.href); // Return immediately if there's no match.
const result = regExp.exec(url.href);
// Return immediately if there's no match.
if (!result) {
return;
} // Require that the match start at the first character in the URL string
}
// Require that the match start at the first character in the URL string
// if it's a cross-origin request.
// See https://github.com/GoogleChrome/workbox/issues/281 for the context
// behind this behavior.
if (url.origin !== location.origin && result.index !== 0) {

@@ -341,16 +316,12 @@ {

}
return;
} // If the route matches, but there aren't any capture groups defined, then
}
// If the route matches, but there aren't any capture groups defined, then
// this will return [], which is truthy and therefore sufficient to
// indicate a match.
// If there are capture groups, then it will return their values.
return result.slice(1);
};
super(match, handler, method);
}
}

@@ -382,3 +353,2 @@

*/
class Router {

@@ -397,4 +367,2 @@ /**

*/
get routes() {

@@ -407,4 +375,2 @@ return this._routes;

*/
addFetchListener() {

@@ -420,3 +386,2 @@ // See https://github.com/Microsoft/TypeScript/issues/28357#issuecomment-436484705

});
if (responsePromise) {

@@ -449,4 +414,2 @@ event.respondWith(responsePromise);

*/
addCacheListener() {

@@ -462,7 +425,5 @@ // See https://github.com/Microsoft/TypeScript/issues/28357#issuecomment-436484705

} = event.data;
{
logger_js.logger.debug(`Caching URLs from the window`, payload.urlsToCache);
}
const requestPromises = Promise.all(payload.urlsToCache.map(entry => {

@@ -472,3 +433,2 @@ if (typeof entry === 'string') {

}
const request = new Request(...entry);

@@ -478,9 +438,9 @@ return this.handleRequest({

event
}); // TODO(philipwalton): TypeScript errors without this typecast for
});
// TODO(philipwalton): TypeScript errors without this typecast for
// some reason (probably a bug). The real type here should work but
// doesn't: `Array<Promise<Response> | undefined>`.
})); // TypeScript
event.waitUntil(requestPromises); // If a MessageChannel was used, reply to the message on success.
event.waitUntil(requestPromises);
// If a MessageChannel was used, reply to the message on success.
if (event.ports && event.ports[0]) {

@@ -504,4 +464,2 @@ void requestPromises.then(() => event.ports[0].postMessage(true));

*/
handleRequest({

@@ -519,5 +477,3 @@ request,

}
const url = new URL(request.url, location.href);
if (!url.protocol.startsWith('http')) {

@@ -527,6 +483,4 @@ {

}
return;
}
const sameOrigin = url.origin === location.origin;

@@ -544,7 +498,5 @@ const {

const debugMessages = [];
{
if (handler) {
debugMessages.push([`Found a route to handle this request:`, route]);
if (params) {

@@ -554,8 +506,6 @@ debugMessages.push([`Passing the following params to the route's handler:`, params]);

}
} // If we don't have a handler because there was no matching route, then
}
// If we don't have a handler because there was no matching route, then
// fall back to defaultHandler if that's defined.
const method = request.method;
if (!handler && this._defaultHandlerMap.has(method)) {

@@ -565,6 +515,4 @@ {

}
handler = this._defaultHandlerMap.get(method);
}
if (!handler) {

@@ -576,6 +524,4 @@ {

}
return;
}
{

@@ -593,8 +539,6 @@ // We have a handler, meaning Workbox is going to handle the route.

logger_js.logger.groupEnd();
} // Wrap in try and catch in case the handle method throws a synchronous
}
// Wrap in try and catch in case the handle method throws a synchronous
// error. It should still callback to the catch handler.
let responsePromise;
try {

@@ -609,7 +553,5 @@ responsePromise = handler.handle({

responsePromise = Promise.reject(err);
} // Get route's catch handler, if it exists
}
// Get route's catch handler, if it exists
const catchHandler = route && route.catchHandler;
if (responsePromise instanceof Promise && (this._catchHandler || catchHandler)) {

@@ -627,3 +569,2 @@ responsePromise = responsePromise.catch(async err => {

}
try {

@@ -642,3 +583,2 @@ return await catchHandler.handle({

}
if (this._catchHandler) {

@@ -653,3 +593,2 @@ {

}
return this._catchHandler.handle({

@@ -661,7 +600,5 @@ url,

}
throw err;
});
}
return responsePromise;

@@ -684,4 +621,2 @@ }

*/
findMatchingRoute({

@@ -694,7 +629,6 @@ url,

const routes = this._routes.get(request.method) || [];
for (const route of routes) {
let params; // route.match returns type any, not possible to change right now.
let params;
// route.match returns type any, not possible to change right now.
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
const matchResult = route.match({

@@ -706,3 +640,2 @@ url,

});
if (matchResult) {

@@ -715,12 +648,11 @@ {

}
} // See https://github.com/GoogleChrome/workbox/issues/2079
}
// See https://github.com/GoogleChrome/workbox/issues/2079
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
params = matchResult;
if (Array.isArray(params) && params.length === 0) {
// Instead of passing an empty array in as params, use undefined.
params = undefined;
} else if (matchResult.constructor === Object && // eslint-disable-line
} else if (matchResult.constructor === Object &&
// eslint-disable-line
Object.keys(matchResult).length === 0) {

@@ -734,5 +666,4 @@ // Instead of passing an empty object in as params, use undefined.

params = undefined;
} // Return early if have a match.
}
// Return early if have a match.
return {

@@ -743,5 +674,4 @@ route,

}
} // If no match was found above, return and empty object.
}
// If no match was found above, return and empty object.
return {};

@@ -763,4 +693,2 @@ }

*/
setDefaultHandler(handler, method = defaultMethod) {

@@ -776,4 +704,2 @@ this._defaultHandlerMap.set(method, normalizeHandler(handler));

*/
setCatchHandler(handler) {

@@ -787,4 +713,2 @@ this._catchHandler = normalizeHandler(handler);

*/
registerRoute(route) {

@@ -823,9 +747,7 @@ {

}
if (!this._routes.has(route.method)) {
this._routes.set(route.method, []);
} // Give precedence to all of the earlier routes by adding this additional
}
// Give precedence to all of the earlier routes by adding this additional
// route to the end of the array.
this._routes.get(route.method).push(route);

@@ -838,4 +760,2 @@ }

*/
unregisterRoute(route) {

@@ -847,5 +767,3 @@ if (!this._routes.has(route.method)) {

}
const routeIndex = this._routes.get(route.method).indexOf(route);
if (routeIndex > -1) {

@@ -857,3 +775,2 @@ this._routes.get(route.method).splice(routeIndex, 1);

}
}

@@ -876,11 +793,9 @@

*/
const getOrCreateDefaultRouter = () => {
if (!defaultRouter) {
defaultRouter = new Router(); // The helpers that use the default Router assume these listeners exist.
defaultRouter = new Router();
// The helpers that use the default Router assume these listeners exist.
defaultRouter.addFetchListener();
defaultRouter.addCacheListener();
}
return defaultRouter;

@@ -914,9 +829,6 @@ };

*/
function registerRoute(capture, handler, method) {
let route;
if (typeof capture === 'string') {
const captureUrl = new URL(capture, location.href);
{

@@ -929,10 +841,8 @@ if (!(capture.startsWith('/') || capture.startsWith('http'))) {

});
} // We want to check if Express-style wildcards are in the pathname only.
}
// We want to check if Express-style wildcards are in the pathname only.
// TODO: Remove this log message in v4.
const valueToCheck = capture.startsWith('http') ? captureUrl.pathname : capture; // See https://github.com/pillarjs/path-to-regexp#parameters
const valueToCheck = capture.startsWith('http') ? captureUrl.pathname : capture;
// See https://github.com/pillarjs/path-to-regexp#parameters
const wildcards = '[*:?+]';
if (new RegExp(`${wildcards}`).exec(valueToCheck)) {

@@ -942,3 +852,2 @@ 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.`);

}
const matchCallback = ({

@@ -952,7 +861,5 @@ url

}
return url.href === captureUrl.href;
}; // If `capture` is a string then `handler` and `method` must be present.
};
// If `capture` is a string then `handler` and `method` must be present.
route = new Route(matchCallback, handler, method);

@@ -974,3 +881,2 @@ } else if (capture instanceof RegExp) {

}
const defaultRouter = getOrCreateDefaultRouter();

@@ -997,3 +903,2 @@ defaultRouter.registerRoute(route);

*/
function setCatchHandler(handler) {

@@ -1023,3 +928,2 @@ const defaultRouter = getOrCreateDefaultRouter();

*/
function setDefaultHandler(handler) {

@@ -1040,3 +944,3 @@ const defaultRouter = getOrCreateDefaultRouter();

}({}, workbox.core._private, workbox.core._private, workbox.core._private, workbox.core._private));
})({}, workbox.core._private, workbox.core._private, workbox.core._private, workbox.core._private);
//# sourceMappingURL=workbox-routing.dev.js.map
{
"name": "workbox-routing",
"version": "7.0.0",
"version": "7.1.0",
"license": "MIT",

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

"dependencies": {
"workbox-core": "7.0.0"
"workbox-core": "7.1.0"
},
"gitHead": "c1d11636823e5e3a89520f7a531970a39304b14a"
"gitHead": "9e69c4269c35e2db9fbba4d13e4e6206c7b66d2a"
}
// @ts-ignore
try{self['workbox:routing:7.0.0']&&_()}catch(e){}
try{self['workbox:routing:7.1.0']&&_()}catch(e){}

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