From ff40d516b1b2816dc739c2ae82ea54cc4b4789f7 Mon Sep 17 00:00:00 2001 From: Nikiforov Alexandr Date: Tue, 8 May 2018 15:10:39 +0700 Subject: [PATCH] =?UTF-8?q?=D0=B8=D0=B7=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D0=B8=D0=B5=20=D0=BE=D1=82=20=D0=BB=D0=B8=D1=88=D0=BD?= =?UTF-8?q?=D0=B8=D1=85=20=D1=81=D0=BB=D0=B5=D1=88=D0=B5=D0=B9=20=D0=B2=20?= =?UTF-8?q?opts.path=20(#7)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/router.tsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/router.tsx b/src/router.tsx index ee404d6..eb48e2b 100644 --- a/src/router.tsx +++ b/src/router.tsx @@ -61,6 +61,7 @@ export default class Router extends React.Component { path: string; location: any; private subscriber: any; + private static clearSlashesRegex = /\/{2,}/g; constructor(props) { super(props); @@ -77,7 +78,9 @@ export default class Router extends React.Component { this.subscriber = null; } static async init(opts: initParams): Promise { - const { path, routes, hooks, history = null, ctx = new Context(), errors, isUniversal, helpers } = opts; + const { routes, hooks, history = null, ctx = new Context(), errors, isUniversal, helpers } = opts; + let { path } = opts; + path = path.replace(this.clearSlashesRegex, '/'); let plainRoutes; if ((Array.isArray(routes) && React.isValidElement(routes[0])) || React.isValidElement(routes)) { plainRoutes = Router.buildRoutes(routes);