microrouter
Advanced tools
Comparing version 3.1.2 to 3.1.3
@@ -8,8 +8,9 @@ function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; } | ||
const methodFn = method => (path, handler) => { | ||
if (!path) throw new Error('You need to set a valid path'); | ||
const methodFn = method => (givenPath, handler) => { | ||
if (!givenPath) throw new Error('You need to set a valid path'); | ||
if (!handler) throw new Error('You need to set a valid handler'); | ||
return (req, res, namespace) => { | ||
const route = !isPattern(path) ? new UrlPattern(`${namespace}${path}`, patternOpts) : path; | ||
const path = givenPath === '/' ? '(/)' : givenPath; | ||
const route = isPattern(path) ? path : new UrlPattern(`${namespace}${path}`, patternOpts); | ||
@@ -16,0 +17,0 @@ const { params, query } = getParamsAndQuery(route, req.url); |
@@ -5,3 +5,4 @@ const { parse } = require('url'); | ||
const patternOpts = { | ||
segmentNameCharset: 'a-zA-Z0-9_-' | ||
segmentNameCharset: 'a-zA-Z0-9_-', | ||
segmentValueCharset: 'a-zA-Z0-9@.+-_' | ||
}; | ||
@@ -8,0 +9,0 @@ |
{ | ||
"name": "microrouter", | ||
"description": "🚉 A tiny and functional router for ZEIT's Micro", | ||
"version": "3.1.2", | ||
"version": "3.1.3", | ||
"main": "dist/lib/index.js", | ||
"jsnext:main": "src/lib/index.js", | ||
"scripts": { | ||
"prerelease": "yarn test && yarn lint && yarn build", | ||
"release": "np", | ||
@@ -9,0 +10,0 @@ "lint": "eslint ./src/**/*.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
18984
259