fix(router): properly serialize aux routes

Previously, routes would be generated with a leading slash after the parens:

    example.com/foo(/bar)

This fix removes the trailing slash when generating the URL, so now we have:

    example.com/foo(bar)

This change is not breaking because we still recognize both forms. We just normalize
without the slash.
This commit is contained in:
Brian Ford 2015-10-30 17:03:19 -07:00
parent d8775e0e1f
commit 23784a2eca
1 changed files with 11 additions and 3 deletions

View File

@ -137,7 +137,7 @@ export function stringifyInstruction(instruction: Instruction): string {
export function stringifyInstructionPath(instruction: Instruction): string {
return instruction.component.urlPath + stringifyAux(instruction) +
stringifyPrimary(instruction.child);
stringifyPrimaryPrefixed(instruction.child);
}
export function stringifyInstructionQuery(instruction: Instruction): string {
@ -146,6 +146,14 @@ export function stringifyInstructionQuery(instruction: Instruction): string {
'';
}
function stringifyPrimaryPrefixed(instruction: Instruction): string {
var primary = stringifyPrimary(instruction);
if (primary.length > 0) {
primary = '/' + primary;
}
return primary;
}
function stringifyPrimary(instruction: Instruction): string {
if (isBlank(instruction)) {
return '';
@ -153,8 +161,8 @@ function stringifyPrimary(instruction: Instruction): string {
var params = instruction.component.urlParams.length > 0 ?
(';' + instruction.component.urlParams.join(';')) :
'';
return '/' + instruction.component.urlPath + params + stringifyAux(instruction) +
stringifyPrimary(instruction.child);
return instruction.component.urlPath + params + stringifyAux(instruction) +
stringifyPrimaryPrefixed(instruction.child);
}
function stringifyAux(instruction: Instruction): string {