Skip to content

Commit

Permalink
MET-3943-Prevent-EMpty-Dataset-Ids
Browse files Browse the repository at this point in the history
  • Loading branch information
andyjmaclean committed Oct 19, 2021
1 parent 2a4a747 commit 437d504
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
7 changes: 7 additions & 0 deletions src/app/_helpers/helpers.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {
appendDiacriticEquivalents,
fromCSL,
fromInputSafeName,
replaceDiacritics
} from '.';
Expand All @@ -22,4 +23,10 @@ describe('Helpers', () => {
expect(replaceDiacritics('Á')).toBe('A');
expect(replaceDiacritics('Ƶ')).toBe('Z');
});

it('should convert comma-separated lists', () => {
expect(fromCSL('1, 2, 3').length).toEqual(3);
expect(fromCSL('1, 2, 3,').length).toEqual(3);
expect(fromCSL('1, 2, 3,,').length).toEqual(3);
});
});
11 changes: 8 additions & 3 deletions src/app/_helpers/string-helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,14 @@ export function toInputSafeName(s: string): string {
/* - splits the string on commas and return the trimmed results
*/
export function fromCSL(s: string): Array<string> {
return s.split(',').map((part: string) => {
return part.trim();
});
return s
.split(',')
.map((part: string) => {
return part.trim();
})
.filter((s: string) => {
return s.length > 0;
});
}

export function getFormValueList(
Expand Down

0 comments on commit 437d504

Please sign in to comment.