Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not use previous value for the slash token #52

Merged
merged 1 commit into from
Dec 26, 2019

Conversation

mrmlnc
Copy link
Contributor

@mrmlnc mrmlnc commented Dec 24, 2019

For some patterns the .parse method returns tokens with correct type but wrong value.

// a/b/**/
[
  [ 'bos', '' ],
  [ 'text', 'a' ],
  [ 'slash', '/' ],
  [ 'text', 'b' ],
  [ 'slash', '/' ],
  [ 'globstar', '**' ],
  [ 'slash', '*' ] // <------------- * — before, / — after
]

// **/a
[
  [ 'bos', '' ],
  [ 'globstar', '**' ],
  [ 'slash', '*' ], // <------------ * — before, / — after
  [ 'text', 'a' ]
]

I don't know where I must write tests for it :)

Copy link
Member

@jonschlinkert jonschlinkert left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Small nitpicks, would you mind making those changes?

Also, how did you find this bug? I appreciate you looking into it. What was the glob pattern you used for your example?

lib/parse.js Outdated
@@ -839,6 +839,7 @@ const parse = (input, options) => {

state.output += prior.output + prev.output;
consume(value + advance());
value = '/';

push({ type: 'slash', value, output: '' });
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch!

Instead of reassigning value, let's move that to the token:

push({ type: 'slash', value: '/', output: '' });

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

JFYI: I use reassigning value only for local consistency within this module (in most cases we use { value } without property value assigning).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for pointing that out, and I appreciate you paying attention to those details!

lib/parse.js Outdated Show resolved Hide resolved
@mrmlnc mrmlnc force-pushed the trivial_fix_slash_type branch from 5a7c2a2 to c3c192d Compare December 24, 2019 08:17
@mrmlnc mrmlnc force-pushed the trivial_fix_slash_type branch from c3c192d to 5e4cd68 Compare December 24, 2019 08:18
@mrmlnc
Copy link
Contributor Author

mrmlnc commented Dec 24, 2019

Also, how did you find this bug?

I'm trying to split pattern into segments. Now these are just experiments:

What was the glob pattern you used for your example?

One of the test patterns in this repository:

@jonschlinkert
Copy link
Member

jonschlinkert commented Dec 24, 2019 via email

@mrmlnc mrmlnc requested a review from jonschlinkert December 26, 2019 05:40
@jonschlinkert jonschlinkert merged commit c28408b into micromatch:master Dec 26, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants