fix(aio): correctly handle "empty" region names
This commit is contained in:
parent
2da3844673
commit
c208f97461
@ -106,7 +106,7 @@ function regionParserImpl(contents, fileType) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function getRegionNames(input) {
|
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) {
|
function removeLast(array, item) {
|
||||||
|
@ -145,8 +145,9 @@ describe('regionParser service', () => {
|
|||||||
it('should parse multiple region names separated by commas', () => {
|
it('should parse multiple region names separated by commas', () => {
|
||||||
const output = regionParser(
|
const output = regionParser(
|
||||||
t('/* #docregion , A, B */', 'abc', '/* #enddocregion B */', '/* #docregion C */', 'xyz',
|
t('/* #docregion , A, B */', 'abc', '/* #enddocregion B */', '/* #docregion C */', 'xyz',
|
||||||
'/* #enddocregion A, C, */'),
|
'/* #enddocregion A, C */', '123', '/* #enddocregion */'),
|
||||||
'test-type');
|
'test-type');
|
||||||
|
expect(output.regions['']).toEqual(t('abc', 'xyz', '123'));
|
||||||
expect(output.regions['A']).toEqual(t('abc', 'xyz'));
|
expect(output.regions['A']).toEqual(t('abc', 'xyz'));
|
||||||
expect(output.regions['B']).toEqual(t('abc'));
|
expect(output.regions['B']).toEqual(t('abc'));
|
||||||
expect(output.regions['C']).toEqual(t('xyz'));
|
expect(output.regions['C']).toEqual(t('xyz'));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user