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#1248AubreyHewes wants to merge 2 commits into
require_tld also supports an array to support validating against known values#1248Conversation
2fe590c to
dca6e84
Compare
profnandaa
left a comment
There was a problem hiding this comment.
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 |
| return false; | ||
| } | ||
| if (Array.isArray(options.require_tld)) { | ||
| // TODO Array.includes though for browser BC does this |
There was a problem hiding this comment.
I am very curious about this comment.
There was a problem hiding this comment.
@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_tldoption can now be aboolean(backwards compatibility) or anarrayof TLDs which first appliesrequire_tld: truelogic and then that the possible TLD is in the passedarray.localhostIS NOTrequire_tld: truelocalhost.tldISrequire_tld: truelocalhostIS NOTrequire_tld: ["tld"]localhost.tldISrequire_tld: ["tld"]localhost.exampleIS 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
🤗