Open charlesomer opened 3 years ago
PR welcome.
@profnandaa I am picking this issue up.. but before that I need some clarification...
Why is this a bug?
FAQ.md
where .md
is perhaps invalid
.md
is indeed a valid TLD, Wikipedia for .md, IANA - Root zone TLD database, IANA - .md
page inforequire_valid_protocol:true
was passed and the protocol is missing?
require_protocol: true
param. By looking at the doc, it looks like the purpose of require_valid_protocol
is not to validate whether a protocol is present or not, but to validate that if a protocol is present it must be in list of valid protocols
.
isUrl
is with require_valid_protocol: true
which will break the existing behaviourrequire_valid_protocol
will imply that the protocol must always be present.As, described by @anirudh-modi above require_valid_protocol
is not to validate to verify the presence of a protocol. Which however can be achieved instead by using require_protocol
option. By using both the options at once the expected behavior can be achieved:
console.log(
validator.isURL('FAQ.md', {
require_protocol: true,
require_valid_protocol: true,
})
);
// returns false
If the bug is because of some different reason, please mention more in here. I would like to work on this if that's the case. Else I think we can close this issue.
I'm seeing the behavior for isURL changed recently. I have a unit test that expects the following to return false,
const urlOptions = {
protocols: [ 'http', 'https' ],
require_tld: false,
require_protocol: false,
require_host: true,
require_valid_protocol: true,
allow_underscores: true,
host_whitelist: false,
host_blacklist: false,
allow_trailing_dot: false,
allow_protocol_relative_urls: false,
disallow_auth: false
}
> validator.isURL('example@domain.com', urlOptions)
true
This was previously returning false
I downgraded the package from 13.6.0 to 13.5.2 and it works as expected
Describe the bug
console.log(validator.isURL('FAQ.md', {require_valid_protocol: true}))
Returns true when I believe it should be false?Additional context Validator.js version: 13.6.0 Node.js version: v16.4.1 OS platform: macOS