-
Notifications
You must be signed in to change notification settings - Fork 11
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
add escapePath
utility function
#36
Conversation
commit: |
bbbce06
to
e76ffe7
Compare
the current status on utility functions from fast-glob (and why i haven't merged this yet) is that i think copying code over isn't ideal and hopefully we find a way to implement these functions in a different way (ideally more optimal?). haven't really looked much into it though. if you manage to reimplement it though, please let me know |
Yeah, that's a good call out. I've shrunk down the code dramatically now and removed probably 90% of the original. I think this is about as simple as it can get now |
interesting, i can notice there's something that could be improved: using a negative lookahead for the leading slash of the pattern, and removing the group names (we can always add them back later). also, |
I made the I'm super nervous about touching the regex as it's not my strong suit and they seem pretty fiddly. I think we can try to improve it a bit, but I'd like to add some tests first. Of course the easiest way to do that would just be to copy the tests from |
Okay, I removed the group names and copied over some tests I'm still too nervous to mess with the regex anymore though. There's not a lot of tests and I've never used a negative lookahead before. I'm not too worried about performance because this is usually just called once or twice in a program's life, so doesn't need to be super optimized. If you still think we should tweak it then I might have to leave that last bit to you |
don't worry, i'll look into it |
escapePath
utility function
d0f4f5e
to
513df58
Compare
Co-authored-by: Ben McCann <[email protected]>
closes #29
I didn't copy any tests over yet as I thought it was worth deciding on a couple of other questions first before investing more time into it
I wasn't quite sure how to handle the license. This project is ISC licensed and fast-glob is MIT licensed. The two licenses are extremely similar, but I think it'd be simplest if they used the same license. Would you be okay with switch to the MIT license? If so, we should probably also confirm with the other contributors to this project, which luckily shouldn't be hard to do given that it's still a relatively new project
I just put everything into the index file for now since it's still relatively small, but would you prefer these to live in a separate file? I took a few liberties in making minor modifications to the
fast-glob
code to keep things simpler. E.g. I replaced theirutils.string.isEmpty
method with directly doingitem !== ''
so that there were fewer methods to copy over - and I also find it easier to read without the extra layer of indirection.