fix(router): retuning string path

This commit is contained in:
Manu Mtz.-Almeida
2018-03-15 17:09:59 +01:00
parent 7c3cba0b92
commit f48d817a85
2 changed files with 8 additions and 7 deletions

View File

@ -2,7 +2,7 @@ import { Build, Component, Element, Event, EventEmitter, Listen, Method, Prop }
import { Config, DomController } from '../../index'; import { Config, DomController } from '../../index';
import { flattenRouterTree, readRedirects, readRoutes } from './utils/parser'; import { flattenRouterTree, readRedirects, readRoutes } from './utils/parser';
import { readNavState, writeNavState } from './utils/dom'; import { readNavState, writeNavState } from './utils/dom';
import { chainToPath, parsePath, readPath, writePath } from './utils/path'; import { chainToPath, generatePath, parsePath, readPath, writePath } from './utils/path';
import { RouteChain, RouteRedirect, RouterEventDetail } from './utils/interfaces'; import { RouteChain, RouteRedirect, RouterEventDetail } from './utils/interfaces';
import { routeRedirect, routerIDsToChain, routerPathToChain } from './utils/matching'; import { routeRedirect, routerIDsToChain, routerPathToChain } from './utils/matching';
import { printRoutes } from './utils/debug'; import { printRoutes } from './utils/debug';
@ -14,7 +14,7 @@ import { printRoutes } from './utils/debug';
export class Router { export class Router {
private routes: RouteChain[]; private routes: RouteChain[];
private previousPath: string[] = null; private previousPath: string = null;
private redirects: RouteRedirect[]; private redirects: RouteRedirect[];
private busy = false; private busy = false;
private init = false; private init = false;
@ -143,9 +143,10 @@ export class Router {
return readPath(window.location, this.base, this.useHash); return readPath(window.location, this.base, this.useHash);
} }
private emitRouteChange(path: string[], redirectedFrom: string[]|null) { private emitRouteChange(path: string[], redirectPath: string[]|null) {
const from = this.previousPath; const from = this.previousPath;
const to = path.slice(); const redirectedFrom = redirectPath ? generatePath(redirectPath) : null;
const to = generatePath(path);
this.previousPath = to; this.previousPath = to;
this.ionRouteChanged.emit({ this.ionRouteChanged.emit({
from, from,

View File

@ -7,9 +7,9 @@ export interface NavOutlet {
} }
export interface RouterEventDetail { export interface RouterEventDetail {
from: string[]|null; from: string|null;
redirectedFrom: string[]|null; redirectedFrom: string|null;
to: string[]; to: string;
} }
export interface RouteRedirect { export interface RouteRedirect {