Skip to content

Commit 29601ef

Browse files
committed
fix: build files
1 parent 21d8aed commit 29601ef

File tree

3 files changed

+27
-7
lines changed

3 files changed

+27
-7
lines changed

Diff for: dist/index.js renamed to dist/lib/index.js

File renamed without changes.

Diff for: dist/utils/index.js

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
const { parse } = require('url');
2+
const UrlPattern = require('url-pattern');
3+
4+
const patternOpts = {
5+
segmentNameCharset: 'a-zA-Z0-9_-'
6+
};
7+
8+
const isPattern = pattern => pattern instanceof UrlPattern;
9+
10+
const getParamsAndQuery = (pattern, url) => {
11+
const { query, pathname } = parse(url, true);
12+
const route = isPattern(pattern) ? pattern : new UrlPattern(pattern, patternOpts);
13+
const params = route.match(pathname);
14+
15+
return { query, params };
16+
};
17+
18+
module.exports = {
19+
getParamsAndQuery,
20+
isPattern,
21+
patternOpts
22+
};

Diff for: package.json

+5-7
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,13 @@
22
"name": "microrouter",
33
"description": "🚉 A tiny and functional router for ZEIT's Micro",
44
"version": "3.1.0",
5-
"main": "dist/index.js",
6-
"jsnext:main": "lib/index.js",
5+
"main": "dist/lib/index.js",
6+
"jsnext:main": "src/lib/index.js",
77
"scripts": {
88
"release": "np",
99
"lint": "eslint ./src/**/*.js",
10-
"build": "yarn lint && rm -rf dist/* && babel src/lib --ignore *.test.js --out-dir dist --copy-files",
10+
"build":
11+
"yarn lint && rm -rf dist/* && babel src --ignore *.test.js --out-dir dist --copy-files",
1112
"test": "nyc ava",
1213
"coverage": "nyc report --reporter=text-lcov | coveralls",
1314
"format": "yarn lint && prettier --write \"src/**/*.js\""
@@ -40,10 +41,7 @@
4041
"node": ">=6.10.0"
4142
},
4243
"lint-staged": {
43-
"src/**/*.js": [
44-
"yarn format",
45-
"git add"
46-
]
44+
"src/**/*.js": ["yarn format", "git add"]
4745
},
4846
"husky": {
4947
"pre-commit": "lint-staged && npm test"

0 commit comments

Comments
 (0)