valid-url icon indicating copy to clipboard operation
valid-url copied to clipboard

False positives

Open atuttle opened this issue 10 years ago • 3 comments

var validator = require('valid-url');
console.log( validator.isWebUri('http://foo') );

prints http://foo (e.g. true), which is not correct. There is no TLD. Valid URLs will have at least one dot and 1 character after the dot.

atuttle avatar Feb 05 '15 18:02 atuttle

Let me check whether this is the behavior of the original perl module or whether it is a bug introduced by me in the "translation". It appears that based on the original spec, the perl module would reject "relative hostnames" as opposed to accept them per RFC, which is the behavior you advocate as well image

ogt avatar Feb 05 '15 18:02 ogt

So, in summary what you are pointing is a bug. i couldn't find anywhere in the perl code the part that is enforcing what he describes in the spec, ie that the authority is an actual TLD. It may take me a couple days to find the time to fix this. (out of job - trying to start my next company)

ogt avatar Feb 05 '15 19:02 ogt

This is not bug. It is a valid URL. For example, you can declare 'foo' in /etc/hosts file for localhost or in your local network DNS-server for resolving internal hosts.

khoden avatar Jun 05 '17 05:06 khoden