test(docs-infra): ignore empty lines in `URLS_TO_REDIRECT.txt` (#41680)

Previously, the `URLS_TO_REDIRECT.txt` file was expected to not contain
any empty lines. This could easily result in test errors when updating
the file, since it is common for IDEs/editors to automatically ensure
there is an empty line at the end of a saved file
([example failure][1]).

This commit updates the test helpers to be able to cope with empty or
whitespace-only lines in `URLS_TO_REDIRECT.txt` by ignoring such lines.

[1]: https://circleci.com/gh/angular/angular/965534

PR Close #41680
This commit is contained in:
George Kalpakas 2021-04-17 20:19:46 +03:00 committed by Andrew Kushnir
parent 3738dbba05
commit 1d6af94cfb
2 changed files with 5 additions and 2 deletions

View File

@ -194,4 +194,4 @@
/start/forms /start/start-forms
/start/routing /start/start-routing
/testing /guide/testing
/testing/first-app-tests.html /guide/testing
/testing/first-app-tests.html /guide/testing

View File

@ -41,7 +41,10 @@ export function loadRedirects(): FirebaseRedirectConfig[] {
export function loadLegacyUrls() {
const pathToLegacyUrls = `${__dirname}/URLS_TO_REDIRECT.txt`;
const urls = readFileSync(pathToLegacyUrls, 'utf8').split('\n').map(line => line.split('\t'));
const urls = readFileSync(pathToLegacyUrls, 'utf8')
.split('\n')
.filter(line => line.trim() !== '')
.map(line => line.split('\t'));
return urls;
}