Skip to content
Permalink
Browse files
fix: handle empty input by returning empty array from parseGitZOutput
  • Loading branch information
iiroj committed Apr 20, 2022
1 parent e8291b0 commit a118817189a5b41168179fe7268903b1d7f4413a
Showing 2 changed files with 9 additions and 2 deletions.
@@ -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')
: []
@@ -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.