Coder Social home page Coder Social logo

glob-to-regexp's People

Contributors

dienluong avatar fitzgen avatar goloroden avatar jamesmessinger avatar larrybattle avatar roccivic avatar sslmda avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

glob-to-regexp's Issues

Please release :)

Now that the correct SPDX identifier has been set in package.json, thanks to dd7b8a0 it would be nice if that could be released on NPM. It would help (at least me) with license validation automation.

Thanks!

handle \ escapes

adding a \ before a glob character should treat it as a plain character. the current behavior ignores it completely.

# Bad behavior.
> globToRegExp('foo\\*bar')
/^foo\.*bar$/

# Expected result:
/^foo\*bar$/

Keep a changelog

First of all, thanks for this great package!

It would be nice if there was an official changelog or maybe release notes for each release so that we know for sure what kind of changes are included and whether an upgrade is the right thing to do. :)

Curly braces are not handled

Curly braces are not handled

> globToRegExp('./resources/lang/{en,fr}/*.json')

Expected:

/^\.\/resources\/lang\/(en|fr)\/.*\.json$/

or (minimatch produces this):

/^(?:\.\/resources\/lang\/en\.json|\.\/resources\/lang\/fr\.json)$/

Actual:

/^\.\/resources\/lang\/\{en\,fr\}\/.*\.json$/

The idea of converting globs to regexes is a good one

The idea of converting globs to regexes is a good one. However, the conversion done by this code is not correct. Using /^..min.js$/ as the regex for ".min.js" is wrong. The dot asterisk (.*) after the carrot will match all characters including forward slashes. That is not how globs are supposed to work. Wikipedia (and other sources) says that a glob asterisk does not match any forward slashes.

Note that
re = globToRegExp("*.min.js");
re.test("http://example.com/jquery.min.js"); // true

is wrong. The asterisk should match "jquery" but not "example/jquery". A globstar (two asterisks) does match slashes, but not a single asterisk. The full rules for a globstar are more complex than I have stated here.

Support negations

This library doesn't support negation globs, here are the docs about it

For example calling globToRegExp('!*.js') returns /^\!.*\.js$/, which matches strings that start with the character !.

It should return a negative regex (lookahead?) instead.

Suggestion for JS version

Hey Nick,

Nice job...

I would suggest, you can make a second version of this, for front-end (browsers js).

I know it's just removing the export... but would be nice to have.

Also a minified version of both ๐Ÿ‘

License

Thanks for your work! Can you please include a License file?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.