microrouter
Advanced tools
Comparing version 2.1.0 to 2.1.1
@@ -0,1 +1,2 @@ | ||
const UrlPattern = require('url-pattern') | ||
const { getParamsAndQuery } = require('../utils') | ||
@@ -9,4 +10,6 @@ | ||
const route = new UrlPattern(path) | ||
return (req, res) => { | ||
const { params, query } = getParamsAndQuery(path, req.url) | ||
const { params, query } = getParamsAndQuery(route, req.url) | ||
@@ -13,0 +16,0 @@ if (params && req.method === method) { |
{ | ||
"name": "microrouter", | ||
"description": "🚉 A tiny and functional router for Zeit's Micro", | ||
"version": "2.1.0", | ||
"main": "lib/index.js", | ||
"version": "2.1.1", | ||
"main": "dist/index.js", | ||
"jsnext:main": "lib/index.js", | ||
"scripts": { | ||
"build": "rm -rf dist/* && babel lib --ignore *.test.js --out-dir dist --copy-files", | ||
"test": "xo && nyc ava", | ||
@@ -18,2 +20,4 @@ "coverage": "nyc report --reporter=text-lcov | coveralls" | ||
"ava": "^0.18.2", | ||
"babel-cli": "^6.24.1", | ||
"babel-plugin-transform-async-to-generator": "^6.24.1", | ||
"coveralls": "^2.11.16", | ||
@@ -38,4 +42,4 @@ "micro": "^7.0.6", | ||
"engines": { | ||
"node": ">=7.6.0" | ||
"node": ">=6.10.0" | ||
} | ||
} |
@@ -64,3 +64,3 @@ :station: _**Micro Router -**_ A tiny and functional router for Zeit's [micro](https://github.com/zeit/micro) | ||
- `patch(path = String, handler = Function)` | ||
- `delete(path = String, handler = Function)` | ||
- `del(path = String, handler = Function)` | ||
- `head(path = String, handler = Function)` | ||
@@ -67,0 +67,0 @@ - `options(path = String, handler = Function)` |
@@ -6,3 +6,3 @@ const { parse } = require('url') | ||
const { query, pathname } = parse(url, true) | ||
const route = new UrlPattern(pattern) | ||
const route = pattern instanceof UrlPattern ? pattern : new UrlPattern(pattern) | ||
const params = route.match(pathname) | ||
@@ -9,0 +9,0 @@ |
const test = require('ava') | ||
const UrlPattern = require('url-pattern') | ||
@@ -14,1 +15,11 @@ const { getParamsAndQuery } = require('./') | ||
}) | ||
test('getParamsAndQuery() with UrlPattern', t => { | ||
const route = new UrlPattern('/hello/:msg') | ||
const url = '/hello/world?id=0' | ||
const { params, query } = getParamsAndQuery(route, url) | ||
t.deepEqual(params, { msg: 'world' }) | ||
t.deepEqual(query, { id: '0' }) | ||
}) |
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
13632
12
163
10