antonioru / antonioru/deep-waters

isURL function is not working as expected in some cases

Open
#2 6 comments 0 reactions 0 assignees View on GitHub
bug enhancement
Dominant language
JavaScript
Stars
201
Forks
8
PR merge metrics
No merged PRs in 30d

Description

Hi,

First of all, I want to congratulate the author because I believe this is a very promising project. And you've obviously put a lot of time into this. If there is any way I can help, please let me know.

Now, to the point: I've been looking into the code and I've found that the isURL function is not always working as expected. For example, the following code returns true:

```
const DW = require("deep-waters");
console.log(DW.isURL("www.google"));
```

As you mentioned in the comments of [isURL.js](https://github.com/antonioru/deep-waters/blob/master/src/isURL.js), the code for this function is derived from [this Stackoverflow question](https://stackoverflow.com/questions/5717093/check-if-a-javascript-string-is-a-url). The example I've used above was also already mentioned in the comments on Stackoverflow as an invalid example.

Now, the question "what is a valid URL?" is indeed quire ambiguous. But to me, "www.google" should return false for this function. In any case, it would be best to either include specific documentation/examples to explain what works and what not. Were you thinking about also adding more documentation to this project?

As a second measure, we can try to improve the regular expression so that it returns false for these type of cases.

What do you think?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.