From 7ce9e06daba64d762d3e2e7cdee25d7226fb88e9 Mon Sep 17 00:00:00 2001 From: Peter Bacon Darwin Date: Sat, 19 Aug 2017 11:02:02 +0100 Subject: [PATCH] fix(aio): do not redirect API pages on archive and next deployments (#18791) PR Close #18791 --- aio/src/app/app.component.spec.ts | 12 ++++++++++++ aio/src/app/app.component.ts | 2 +- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/aio/src/app/app.component.spec.ts b/aio/src/app/app.component.spec.ts index 23831fd3ee..15638cd345 100644 --- a/aio/src/app/app.component.spec.ts +++ b/aio/src/app/app.component.spec.ts @@ -792,6 +792,10 @@ describe('AppComponent', () => { createTestingModule('api', 'archive'); initializeTest(); expect(TestBed.get(LocationService).replace).not.toHaveBeenCalled(); + + createTestingModule('api/core/getPlatform', 'archive'); + initializeTest(); + expect(TestBed.get(LocationService).replace).not.toHaveBeenCalled(); }); it('should redirect to `docs` if deployment mode is `next` and not at a docs page', () => { @@ -822,6 +826,10 @@ describe('AppComponent', () => { createTestingModule('api', 'next'); initializeTest(); expect(TestBed.get(LocationService).replace).not.toHaveBeenCalled(); + + createTestingModule('api/core/getPlatform', 'next'); + initializeTest(); + expect(TestBed.get(LocationService).replace).not.toHaveBeenCalled(); }); it('should not redirect to `docs` if deployment mode is `stable` and not at a docs page', () => { @@ -852,6 +860,10 @@ describe('AppComponent', () => { createTestingModule('api', 'stable'); initializeTest(); expect(TestBed.get(LocationService).replace).not.toHaveBeenCalled(); + + createTestingModule('api/core/getPlatform', 'stable'); + initializeTest(); + expect(TestBed.get(LocationService).replace).not.toHaveBeenCalled(); }); }); }); diff --git a/aio/src/app/app.component.ts b/aio/src/app/app.component.ts index 84c283ded8..0729636a53 100644 --- a/aio/src/app/app.component.ts +++ b/aio/src/app/app.component.ts @@ -131,7 +131,7 @@ export class AppComponent implements OnInit { this.locationService.currentPath.subscribe(path => { // Redirect to docs if we are in not in stable mode and are not hitting a docs page // (i.e. we have arrived at a marketing page) - if (this.deployment.mode !== 'stable' && !/^(docs$|api$|guide|tutorial)/.test(path)) { + if (this.deployment.mode !== 'stable' && !/^(docs$|api|guide|tutorial)/.test(path)) { this.locationService.replace('docs'); } if (path === this.currentPath) {