Skip to content

Commit

Permalink
Merge pull request #126 from connor4312/issue-125
Browse files Browse the repository at this point in the history
fix bad `text` values in `parse`
  • Loading branch information
jonschlinkert authored Feb 8, 2024
2 parents c0f9c55 + 563f534 commit 2677de2
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/parse.js
Original file line number Diff line number Diff line change
Expand Up @@ -209,8 +209,8 @@ const parse = (input, options) => {

if (tok.value || tok.output) append(tok);
if (prev && prev.type === 'text' && tok.type === 'text') {
prev.output = (prev.output || prev.value) + tok.value;
prev.value += tok.value;
prev.output = (prev.output || '') + tok.value;
return;
}

Expand Down
16 changes: 16 additions & 0 deletions test/api.picomatch.js
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,22 @@ describe('picomatch', () => {

assertTokens(tokens, expected);
});

it('pictomatch issue#125, issue#100', () => {
const { tokens } = picomatch.parse('foo.(m|c|)js');

const expected = [
['bos', { output: '', value: '' }],
['text', { output: 'foo.', value: 'foo.' }],
['paren', { output: undefined, value: '(' }],
['text', { output: 'm|c|', value: 'm|c|' }],
['paren', { output: ')', value: ')' }],
['text', { output: undefined, value: 'js' }]
];

const keyValuePairs = tokens.map(token => [token.type, { output: token.output, value: token.value }]);
assert.deepStrictEqual(keyValuePairs, expected);
});
});
});

Expand Down

0 comments on commit 2677de2

Please sign in to comment.