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

Globs starting with ** fail if the current path and the matched-with path have nothing in common #72

Open
rrousselGit opened this issue Feb 20, 2023 · 1 comment

Comments

@rrousselGit
Copy link

rrousselGit commented Feb 20, 2023

Consider:

Glob('**.dart');

If you are within:

/private/var/folders/68/t6gjyz1j7t5gzhvzbzwczpr80000gn/T/8kbZAb

and check against:

/Users/remirousselet/dev/whatever.dart

then glob.matches returns false.

This seems to be because:

  • The ** ast returns canMatchAbsolute => false
  • This causes Glob.matchAsPrefix to merge the current and tested paths, in this case:
    ../../../../../../../Users/remirousselet/dev/whatever.dart
    
  • the ** ast doesn't matches against ../ paths as per _toRegExp's comment:
    // Double star shouldn't match paths with a leading "../", since these paths
    // wouldn't be listed with this glob. We only check for "../" at the
    // beginning since the paths are normalized before being checked against the
    // glob.
    
@rrousselGit
Copy link
Author

Here's a regression test :)

test('absolute path fully dissociate from current path', () {
  expect(
    '/foo/bar/file.dart',
    contains(
      Glob('**.dart', context: p.Context(current: '/baz/quaz')),
    ),
  );
});

I'm currently investigating if there's an easy fix.

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

No branches or pull requests

1 participant