fix(aio): do not redirect API pages on archive and next deployments (#18791)

PR Close #18791
This commit is contained in:
Peter Bacon Darwin 2017-08-19 11:02:02 +01:00 committed by Miško Hevery
parent 8ea6c56fe1
commit 7ce9e06dab
2 changed files with 13 additions and 1 deletions

View File

@ -792,6 +792,10 @@ describe('AppComponent', () => {
createTestingModule('api', 'archive'); createTestingModule('api', 'archive');
initializeTest(); initializeTest();
expect(TestBed.get(LocationService).replace).not.toHaveBeenCalled(); 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', () => { 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'); createTestingModule('api', 'next');
initializeTest(); initializeTest();
expect(TestBed.get(LocationService).replace).not.toHaveBeenCalled(); 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', () => { 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'); createTestingModule('api', 'stable');
initializeTest(); initializeTest();
expect(TestBed.get(LocationService).replace).not.toHaveBeenCalled(); expect(TestBed.get(LocationService).replace).not.toHaveBeenCalled();
createTestingModule('api/core/getPlatform', 'stable');
initializeTest();
expect(TestBed.get(LocationService).replace).not.toHaveBeenCalled();
}); });
}); });
}); });

View File

@ -131,7 +131,7 @@ export class AppComponent implements OnInit {
this.locationService.currentPath.subscribe(path => { this.locationService.currentPath.subscribe(path => {
// Redirect to docs if we are in not in stable mode and are not hitting a docs page // 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) // (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'); this.locationService.replace('docs');
} }
if (path === this.currentPath) { if (path === this.currentPath) {