fix(aio): correctly handle "empty" region names

This commit is contained in:
Peter Bacon Darwin 2017-02-21 17:54:57 +00:00 committed by Igor Minar
parent 2da3844673
commit c208f97461
2 changed files with 3 additions and 2 deletions

View File

@ -106,7 +106,7 @@ function regionParserImpl(contents, fileType) {
}
function getRegionNames(input) {
return input.split(',').map(name => name.trim()).filter(name => name.length > 0);
return (input.trim() === '') ? [] : input.split(',').map(name => name.trim());
}
function removeLast(array, item) {

View File

@ -145,8 +145,9 @@ describe('regionParser service', () => {
it('should parse multiple region names separated by commas', () => {
const output = regionParser(
t('/* #docregion , A, B */', 'abc', '/* #enddocregion B */', '/* #docregion C */', 'xyz',
'/* #enddocregion A, C, */'),
'/* #enddocregion A, C */', '123', '/* #enddocregion */'),
'test-type');
expect(output.regions['']).toEqual(t('abc', 'xyz', '123'));
expect(output.regions['A']).toEqual(t('abc', 'xyz'));
expect(output.regions['B']).toEqual(t('abc'));
expect(output.regions['C']).toEqual(t('xyz'));