Skip to content

Commit

Permalink
fix: build files
Browse files Browse the repository at this point in the history
  • Loading branch information
pedronauck committed Mar 6, 2018
1 parent 21d8aed commit 29601ef
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 7 deletions.
File renamed without changes.
22 changes: 22 additions & 0 deletions dist/utils/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
const { parse } = require('url');
const UrlPattern = require('url-pattern');

const patternOpts = {
segmentNameCharset: 'a-zA-Z0-9_-'
};

const isPattern = pattern => pattern instanceof UrlPattern;

const getParamsAndQuery = (pattern, url) => {
const { query, pathname } = parse(url, true);
const route = isPattern(pattern) ? pattern : new UrlPattern(pattern, patternOpts);
const params = route.match(pathname);

return { query, params };
};

module.exports = {
getParamsAndQuery,
isPattern,
patternOpts
};
12 changes: 5 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@
"name": "microrouter",
"description": "🚉 A tiny and functional router for ZEIT's Micro",
"version": "3.1.0",
"main": "dist/index.js",
"jsnext:main": "lib/index.js",
"main": "dist/lib/index.js",
"jsnext:main": "src/lib/index.js",
"scripts": {
"release": "np",
"lint": "eslint ./src/**/*.js",
"build": "yarn lint && rm -rf dist/* && babel src/lib --ignore *.test.js --out-dir dist --copy-files",
"build":
"yarn lint && rm -rf dist/* && babel src --ignore *.test.js --out-dir dist --copy-files",
"test": "nyc ava",
"coverage": "nyc report --reporter=text-lcov | coveralls",
"format": "yarn lint && prettier --write \"src/**/*.js\""
Expand Down Expand Up @@ -40,10 +41,7 @@
"node": ">=6.10.0"
},
"lint-staged": {
"src/**/*.js": [
"yarn format",
"git add"
]
"src/**/*.js": ["yarn format", "git add"]
},
"husky": {
"pre-commit": "lint-staged && npm test"
Expand Down

0 comments on commit 29601ef

Please sign in to comment.