fix(router): allow generating links with numeric params
This commit is contained in:
@ -5,8 +5,7 @@ import {
|
||||
StringWrapper,
|
||||
isPresent,
|
||||
isBlank,
|
||||
BaseException,
|
||||
normalizeBlank
|
||||
BaseException
|
||||
} from 'angular2/src/facade/lang';
|
||||
import {Promise, PromiseWrapper} from 'angular2/src/facade/async';
|
||||
import {
|
||||
@ -29,6 +28,14 @@ export class Segment {
|
||||
regex: string;
|
||||
}
|
||||
|
||||
function normalizeString(obj: any): string {
|
||||
if (isBlank(obj)) {
|
||||
return null;
|
||||
} else {
|
||||
return obj.toString();
|
||||
}
|
||||
}
|
||||
|
||||
class ContinuationSegment extends Segment {
|
||||
generate(params): string { return ''; }
|
||||
}
|
||||
@ -56,7 +63,7 @@ class DynamicSegment {
|
||||
throw new BaseException(
|
||||
`Route generator for '${this.name}' was not included in parameters passed.`);
|
||||
}
|
||||
return normalizeBlank(StringMapWrapper.get(params, this.name));
|
||||
return normalizeString(StringMapWrapper.get(params, this.name));
|
||||
}
|
||||
}
|
||||
|
||||
@ -66,7 +73,7 @@ class StarSegment {
|
||||
constructor(public name: string) {}
|
||||
|
||||
generate(params: StringMap<string, string>): string {
|
||||
return normalizeBlank(StringMapWrapper.get(params, this.name));
|
||||
return normalizeString(StringMapWrapper.get(params, this.name));
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user