diff --git a/aio/src/app/app.component.spec.ts b/aio/src/app/app.component.spec.ts index 62f345f85900f..ce1c4d75c3702 100644 --- a/aio/src/app/app.component.spec.ts +++ b/aio/src/app/app.component.spec.ts @@ -417,6 +417,15 @@ describe('AppComponent', () => { selectElement.triggerEventHandler('change', { option: versionWithoutUrl, index: versionWithoutUrlIndex }); expect(locationService.go).not.toHaveBeenCalled(); }); + + it('should navigate when change to a version with a url that does not end with `/`', async () => { + await setupSelectorForTesting(); + locationService.urlSubject.next('docs#section-1'); + const versionWithoutSlashIndex = component.docVersions.length; + const versionWithoutSlashUrl = component.docVersions[versionWithoutSlashIndex] = { url: 'https://next.angular.io', title: 'foo' }; + selectElement.triggerEventHandler('change', { option: versionWithoutSlashUrl, index: versionWithoutSlashIndex }); + expect(locationService.go).toHaveBeenCalledWith('https://next.angular.io/docs#section-1'); + }); }); describe('currentDocument', () => { diff --git a/aio/src/app/app.component.ts b/aio/src/app/app.component.ts index b5fa56c11debc..bedd8046131fb 100644 --- a/aio/src/app/app.component.ts +++ b/aio/src/app/app.component.ts @@ -149,8 +149,8 @@ export class AppComponent implements OnInit { ]).subscribe(([versionInfo, versions]) => { // TODO(pbd): consider whether we can lookup the stable and next versions from the internet const computedVersions: NavigationNode[] = [ - { title: 'next', url: 'https://next.angular.io' }, - { title: 'stable', url: 'https://angular.io' }, + { title: 'next', url: 'https://next.angular.io/' }, + { title: 'stable', url: 'https://angular.io/' }, ]; if (this.deployment.mode === 'archive') { computedVersions.push({ title: `v${versionInfo.major}` }); @@ -232,7 +232,8 @@ export class AppComponent implements OnInit { onDocVersionChange(versionIndex: number) { const version = this.docVersions[versionIndex]; if (version.url) { - this.locationService.go(`${version.url}${this.currentUrl}`); + const versionUrl = version.url + (!version.url.endsWith('/') ? '/' : ''); + this.locationService.go(`${versionUrl}${this.currentUrl}`); } }