stacks-cli
stacks-cli copied to clipboard
Handle missing scheme
Entering a URL without a scheme causes the process to exit silently:
$ stacks-cli
? Which website stack do you wanna browse ? (e.g. https://github.com) github.com
โโโโโโโโโโโคโโโโโโโโโโคโโโโโโโโโโโโโโโโคโโโโโโโโโโโโโโโโคโโโโโโโโโโโโโ
โ ๐ท type โ ๐ name โ ๐ช confidence โ โ categories โ ๐ป website โ
โโโโโโโโโโโงโโโโโโโโโโงโโโโโโโโโโโโโโโโงโโโโโโโโโโโโโโโโงโโโโโโโโโโโโโ
$ echo $?
0
Would it be reasonable to assume https://
or https://
if the entered URL lacks a scheme?
This should be fixed here https://github.com/WeiChiaChang/stacks-cli/pull/25/files#diff-22d5d2b57c69d2e1ac054c4d0f744ff1R87 ๐
That fixes the silent exit. ๐
It would be great if it would also specifically handle the missing scheme in a more friendly way, for example by defaulting to https://
/http://
or with a helpful error message.
Yes, using https://github.com/epoberezkin/ajv#formats !
Why use an entire validation library?
if(inputstr.indexOf("http://") < 0 && inputstr.indexOf("https://") < 0){
console.log("No scheme found, defaulting to http");
inputstr = "http://" + inputstr;
}
That's all you need.
Send a PR @dospunk !