cmdo-router
Advanced tools
Comparing version 1.2.2 to 1.2.3
@@ -6,4 +6,4 @@ import type { History, Location } from "./History"; | ||
export declare class Router { | ||
readonly history: History; | ||
readonly base: string; | ||
readonly history: History; | ||
routes: Route[]; | ||
@@ -10,0 +10,0 @@ query: Query; |
@@ -46,5 +46,5 @@ "use strict"; | ||
function Router(history, _a) { | ||
var _b = (_a === void 0 ? {} : _a).base, base = _b === void 0 ? "" : _b; | ||
var base = (_a === void 0 ? {} : _a).base; | ||
this.routes = []; | ||
this.base = base; | ||
this.base = getBase(base); | ||
this.history = history; | ||
@@ -148,3 +148,3 @@ this.query = new Query_1.Query(history); | ||
if (state === void 0) { state = {}; } | ||
this.history.push(this.base + path, state); | ||
this.history.push((this.base + path.replace(this.base, "")).replace(/\/$/, ""), state); | ||
}; | ||
@@ -175,1 +175,7 @@ Router.prototype.get = function (path) { | ||
} | ||
function getBase(path) { | ||
if (!path || path === "" || path === "/") { | ||
return ""; | ||
} | ||
return path; | ||
} |
{ | ||
"name": "cmdo-router", | ||
"description": "Framework agnostic routing solution for single page web applications.", | ||
"version": "1.2.2", | ||
"version": "1.2.3", | ||
"author": "Christoffer Rodvik <christoffer@kodemon.net>", | ||
@@ -18,2 +18,3 @@ "license": "MIT", | ||
"build": "rm -rf ./dist && tsc", | ||
"dev": "tsc --watch", | ||
"test": "node --inspect node_modules/.bin/jest --runInBand --verbose" | ||
@@ -20,0 +21,0 @@ }, |
59435
1557