Skip to content

Commit

Permalink
избавление от лишних слешей в opts.path (#7)
Browse files Browse the repository at this point in the history
  • Loading branch information
KefirNot authored and olegman committed May 8, 2018
1 parent b189d87 commit ff40d51
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/router.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ export default class Router extends React.Component<Props, State> {
path: string;
location: any;
private subscriber: any;
private static clearSlashesRegex = /\/{2,}/g;
constructor(props) {
super(props);

Expand All @@ -77,7 +78,9 @@ export default class Router extends React.Component<Props, State> {
this.subscriber = null;
}
static async init(opts: initParams): Promise<initResult> {
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);
Expand Down

0 comments on commit ff40d51

Please sign in to comment.