-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
isFQDN option require_tld
also supports an array to support validating against known values
#1248
isFQDN option require_tld
also supports an array to support validating against known values
#1248
Conversation
2fe590c
to
dca6e84
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your 1st contrib! 🎉 This LGTM.
Let me hear what the rest think on the comments you've made in the listed issues, then we can land this.
A possible other solution is to introduce an extra option.. (so keeping the interface stricter) though as this method is used by upstream methods this would also require adding the extra option (or option possibility) to the upstream methods. This would entail a much larger change |
@@ -30,6 +30,10 @@ export default function isFQDN(str, options) { | |||
if (/[\s\u2002-\u200B\u202F\u205F\u3000\uFEFF\uDB40\uDC20]/.test(tld)) { | |||
return false; | |||
} | |||
if (Array.isArray(options.require_tld)) { | |||
// TODO Array.includes though for browser BC does this |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am very curious about this comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ezkemboi yeah I am as well, comment should be removed.. and includes should be used (next line).. though then IE is no longer supported.
Thank you @AubreyHewes for your first PR 🎉 ! I really like the idea of handling multiple TLDs from user side and having this feature backward compatible but i have two issues related to api/lib consistency:
Also, i guess the readme entry and transpilled version for the change are missing in the PR. Generally, I agree more with the second solution of introducing a new option for handling this. |
Ping @AubreyHewes |
@profnandaa Sorry was indisposed.. So what do you want? It seems, a second option that iterates through all usages, so this would require a second option to all usages of the The option behaviour change actually reduces the amount of required code. Reducing the library footprint. We could typescript it as either a boolean or an array then it would be explicit for a user. |
@AubreyHewes -- sorry about that, good to see you back. |
@AubreyHewes not sure typescript typescript declaration would work unless you use typescript or vscode? What i'd like to see is either have a my 2 cents. |
To summarize; a new option would require a new option to all current and future usages of the my 2cts ;-) good luck with your first PR #1297 as that does what the feedback was for this.. When I asked if that is what was wanted I never got an answer. (I do not completely agree with #1297 but, hey that is what forks are for! 👍 ) |
This just adds the possibility of validating against a list of given TLD values...
The
require_tld
option can now be aboolean
(backwards compatibility) or anarray
of TLDs which first appliesrequire_tld: true
logic and then that the possible TLD is in the passedarray
.localhost
IS NOTrequire_tld: true
localhost.tld
ISrequire_tld: true
localhost
IS NOTrequire_tld: ["tld"]
localhost.tld
ISrequire_tld: ["tld"]
localhost.example
IS NOTrequire_tld: ["tld"]
This gives more options to the developer, for example, checking the TLD against the IANA gTLD list
Checking against the list itself SHOULD NOT be part of the library.
solves #1193 #1247 #704 #1180
🤗