fix(docs-infra): do not redirect docs URLs on archive deployments (#30894)

To avoid showing outdated info (such as events, resources, etc.) but
still allow people to see docs for older versions, we redirect
non-documentation URLs to `/docs`. Recently(-ish) we have added
documentation content under the `/cli/...` and `/start/...`
path-prefixes, but we haven't added them to the list of documentation
URLs that should not be redirected. As a result, on archive deployments
(e.g. https://v7.angular.io/cli), they are redirected to `/docs`, making
it impossible to see the documentation for these versions (unless you
know about the `?mode=stable` work-around).

This commit fixes it by adding `cli` and `start` to the list of
documentation URLs that are excluded from redirection.

PR Close #30894
This commit is contained in:
George Kalpakas 2019-06-09 20:22:02 +03:00 committed by Igor Minar
parent 93af1f8456
commit a2cd401a2e
2 changed files with 9 additions and 1 deletions

View File

@ -837,6 +837,10 @@ describe('AppComponent', () => {
initializeTest(false); initializeTest(false);
verifyNoRedirection(); verifyNoRedirection();
createTestingModule('start', mode);
initializeTest(false);
verifyNoRedirection();
createTestingModule('tutorial', mode); createTestingModule('tutorial', mode);
initializeTest(false); initializeTest(false);
verifyNoRedirection(); verifyNoRedirection();
@ -849,6 +853,10 @@ describe('AppComponent', () => {
initializeTest(false); initializeTest(false);
verifyNoRedirection(); verifyNoRedirection();
createTestingModule('cli', mode);
initializeTest(false);
verifyNoRedirection();
createTestingModule('api', mode); createTestingModule('api', mode);
initializeTest(false); initializeTest(false);
verifyNoRedirection(); verifyNoRedirection();

View File

@ -122,7 +122,7 @@ export class AppComponent implements OnInit {
this.locationService.currentPath.subscribe(path => { this.locationService.currentPath.subscribe(path => {
// Redirect to docs if we are in archive mode and are not hitting a docs page // Redirect to docs if we are in archive 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 === 'archive' && !/^(docs$|api|guide|tutorial)/.test(path)) { if (this.deployment.mode === 'archive' && !/^(docs$|api|cli|guide|start|tutorial)/.test(path)) {
this.locationService.replace('docs'); this.locationService.replace('docs');
} }
if (path === this.currentPath) { if (path === this.currentPath) {