-
Notifications
You must be signed in to change notification settings - Fork 10
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
Match whole strings instead of partial strings when using patterns #13
Comments
I see what you mean and agree that the names you mentioned seem harmless. I'm sure part of the original motivation for some of these is to prevent spoofing. Let's say these sub-domains are used on a blog platform, where the site can be fully customized. A user could create a subdomain like Maybe instead of matching the whole string we matched on boundaries. So the /(^|-|_)mx[0-9]+/.test('www-mx1') // true
/(^|-|_)mx[0-9]+/.test('bmx1') // false
/(^|-|_)mx[0-9]+/.test('mx1') // true Now I also see that the rules are using /(^|-|_)ftp[0-9]+/.test('ftp') // false -- this should be true
/(^|-|_)ftp[0-9]*/.test('ftp') // true -- uses * instead |
Okay, that seems acceptable. Maybe the same boundary rule can be applied to the end too?
Because with something like |
Sounds reasonable. Ideally a PR addressing these things would also introduce tests so expected behavior is kept in check. The changes we've discussed would technically be a breaking change (major version bump) even if the API doesn't change. But with that said, this might be a good time to review the API ergonomics/idioms, considering TypeScript, etc... Thanks for getting involved in the project. |
Yes, I think a way to add names and patterns to the bundled list would be nice. Apart from that, I also noticed that auto-import did not work for me on vscode. I'm not sure why, maybe it doesn't work for certain kinds of exports? This needs to be investigated further. |
I feel it would be better if patterns matched only whole strings instead of partial strings. For example
^m[0-9]+$
instead ofm[0-9]+
. Because the following harmless names end up failing validation:This could be remedied by changing the pattern list to:
Should I send a PR?
The text was updated successfully, but these errors were encountered: