Skip to content

Commit

Permalink
fixed bug in publish script
Browse files Browse the repository at this point in the history
  • Loading branch information
jmhdez committed Jul 19, 2016
1 parent 7412876 commit 35cec67
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
24 changes: 12 additions & 12 deletions lib/Router.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,23 +48,23 @@ function getQueryParams(query) {
};

function createRoute(name, path, handler) {
var matcher = new RegExp(path.replace(parametersPattern, '([^\/]+)'));
var matcher = new RegExp(path.replace(parametersPattern, '([^\/]+)') + '$');
var params = (path.match(parametersPattern) || []).map(function (x) {
return x.substring(1);
});

return { name: name, path: path, handler: handler, matcher: matcher, params: params };
};

function findRouteParams(routes, path) {
var findRouteParams = function findRouteParams(routes, path) {
var params = void 0;
var route = routes.find(function (r) {
return params = getMatchedParams(r, path);
});
return route && { route: route, params: params };
}
return { route: route, params: params };
};

function parseUrl(url) {
var parseUrl = function parseUrl(url) {
var _url$split = url.split('?');

var _url$split2 = _slicedToArray(_url$split, 2);
Expand All @@ -73,7 +73,11 @@ function parseUrl(url) {
var queryString = _url$split2[1];

return { path: path, queryString: queryString };
}
};

var stripPrefix = function stripPrefix(url, prefix) {
return url.replace(new RegExp('^' + prefix), '');
};

// The actual Router as the default export of the module

Expand Down Expand Up @@ -107,9 +111,7 @@ var Router = function () {
}, {
key: 'dispatch',
value: function dispatch(url) {
var urlWithoutPrefix = url.replace(new RegExp('^' + this.prefix), '');

var _parseUrl = parseUrl(urlWithoutPrefix);
var _parseUrl = parseUrl(stripPrefix(url, this.prefix));

var path = _parseUrl.path;
var queryString = _parseUrl.queryString;
Expand All @@ -132,9 +134,7 @@ var Router = function () {
}, {
key: 'getCurrentRoute',
value: function getCurrentRoute(url) {
var urlWithoutPrefix = url.replace(new RegExp('^' + this.prefix), '');

var _parseUrl2 = parseUrl(urlWithoutPrefix);
var _parseUrl2 = parseUrl(stripPrefix(url, this.prefix));

var path = _parseUrl2.path;
var queryString = _parseUrl2.queryString;
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
{
"name": "minimal-router",
"version": "1.0.3",
"version": "1.0.5",
"description": "A minimalist router for client-side javascript applications",
"main": "lib/index.js",
"scripts": {
"test": "mocha test --compilers js:babel-register",
"build": "babel src -d lib",
"build:browser": "browserify src/index.js -t [ babelify ] --standalone Router | uglifyjs > dist/minimal-router.min.js",
"dev": "mocha test --watch --compilers js:babel-register",
"prepublish": "npm test && npm build && npm run build:browser"
"prepublish": "npm test && npm run build && npm run build:browser"
},
"repository": {
"type": "git",
Expand Down

0 comments on commit 35cec67

Please sign in to comment.