Skip to content

Commit

Permalink
fix: handle empty input by returning empty array from parseGitZOutput
Browse files Browse the repository at this point in the history
  • Loading branch information
iiroj committed Apr 20, 2022
1 parent e8291b0 commit a118817
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/parseGitZOutput.js
Expand Up @@ -5,5 +5,7 @@
*/
export const parseGitZOutput = (input) =>
input
.replace(/\u0000$/, '') // eslint-disable-line no-control-regex
.split('\u0000')
? input
.replace(/\u0000$/, '') // eslint-disable-line no-control-regex
.split('\u0000')
: []
5 changes: 5 additions & 0 deletions test/parseGitZOutput.spec.js
Expand Up @@ -10,4 +10,9 @@ describe('parseGitZOutput', () => {
const input = 'a\u0000'
expect(parseGitZOutput(input)).toEqual(['a'])
})

it('should handle empty input', () => {
const input = ''
expect(parseGitZOutput(input)).toEqual([])
})
})

0 comments on commit a118817

Please sign in to comment.