@ -93,8 +93,8 @@ var wildcardMatcher = /^\*([^\/]+)$/g;
|
||||
function parsePathString(route: string): {[key: string]: any} {
|
||||
// normalize route as not starting with a "/". Recognition will
|
||||
// also normalize.
|
||||
if (StringWrapper.startsWith(route, "/")) {
|
||||
route = StringWrapper.substring(route, 1);
|
||||
if (route.startsWith("/")) {
|
||||
route = route.substring(1);
|
||||
}
|
||||
|
||||
var segments = splitBySlash(route);
|
||||
|
@ -1,7 +1,6 @@
|
||||
import {
|
||||
RegExp,
|
||||
RegExpWrapper,
|
||||
StringWrapper,
|
||||
isBlank,
|
||||
isPresent,
|
||||
isType,
|
||||
@ -46,8 +45,7 @@ export class RouteRecognizer {
|
||||
|
||||
if (config instanceof AuxRoute) {
|
||||
handler = new SyncRouteHandler(config.component, config.data);
|
||||
let path =
|
||||
StringWrapper.startsWith(config.path, '/') ? config.path.substring(1) : config.path;
|
||||
let path = config.path.startsWith('/') ? config.path.substring(1) : config.path;
|
||||
var recognizer = new PathRecognizer(config.path, handler);
|
||||
this.auxRoutes.set(path, recognizer);
|
||||
return recognizer.terminal;
|
||||
@ -136,11 +134,11 @@ export class Redirector {
|
||||
toSegments: string[] = [];
|
||||
|
||||
constructor(path: string, redirectTo: string) {
|
||||
if (StringWrapper.startsWith(path, '/')) {
|
||||
if (path.startsWith('/')) {
|
||||
path = path.substring(1);
|
||||
}
|
||||
this.segments = path.split('/');
|
||||
if (StringWrapper.startsWith(redirectTo, '/')) {
|
||||
if (redirectTo.startsWith('/')) {
|
||||
redirectTo = redirectTo.substring(1);
|
||||
}
|
||||
this.toSegments = redirectTo.split('/');
|
||||
|
@ -5,14 +5,7 @@ import {
|
||||
ObservableWrapper
|
||||
} from 'angular2/src/core/facade/async';
|
||||
import {Map, StringMapWrapper, MapWrapper, ListWrapper} from 'angular2/src/core/facade/collection';
|
||||
import {
|
||||
isBlank,
|
||||
isString,
|
||||
StringWrapper,
|
||||
isPresent,
|
||||
Type,
|
||||
isArray
|
||||
} from 'angular2/src/core/facade/lang';
|
||||
import {isBlank, isString, isPresent, Type, isArray} from 'angular2/src/core/facade/lang';
|
||||
import {BaseException, WrappedException} from 'angular2/src/core/facade/exceptions';
|
||||
import {RouteRegistry} from './route_registry';
|
||||
import {
|
||||
@ -537,11 +530,11 @@ class ChildRouter extends Router {
|
||||
* Given: ['/a/b', {c: 2}]
|
||||
* Returns: ['', 'a', 'b', {c: 2}]
|
||||
*/
|
||||
var SLASH = new RegExp('/');
|
||||
function splitAndFlattenLinkParams(linkParams: any[]): any[] {
|
||||
return ListWrapper.reduce(linkParams, (accumulation, item) => {
|
||||
if (isString(item)) {
|
||||
return accumulation.concat(StringWrapper.split(item, SLASH));
|
||||
let parts: String[] = item.split('/');
|
||||
return accumulation.concat(parts);
|
||||
}
|
||||
accumulation.push(item);
|
||||
return accumulation;
|
||||
|
@ -1,11 +1,5 @@
|
||||
import {StringMapWrapper} from 'angular2/src/core/facade/collection';
|
||||
import {
|
||||
isPresent,
|
||||
isBlank,
|
||||
StringWrapper,
|
||||
RegExpWrapper,
|
||||
CONST_EXPR
|
||||
} from 'angular2/src/core/facade/lang';
|
||||
import {isPresent, isBlank, RegExpWrapper, CONST_EXPR} from 'angular2/src/core/facade/lang';
|
||||
import {BaseException, WrappedException} from 'angular2/src/core/facade/exceptions';
|
||||
|
||||
/**
|
||||
@ -79,10 +73,10 @@ function matchUrlSegment(str: string): string {
|
||||
export class UrlParser {
|
||||
private _remaining: string;
|
||||
|
||||
peekStartsWith(str: string): boolean { return StringWrapper.startsWith(this._remaining, str); }
|
||||
peekStartsWith(str: string): boolean { return this._remaining.startsWith(str); }
|
||||
|
||||
capture(str: string): void {
|
||||
if (!StringWrapper.startsWith(this._remaining, str)) {
|
||||
if (!this._remaining.startsWith(str)) {
|
||||
throw new BaseException(`Expected "${str}".`);
|
||||
}
|
||||
this._remaining = this._remaining.substring(str.length);
|
||||
|
Reference in New Issue
Block a user