Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle missing scheme #24

Open
ppvg opened this issue Nov 29, 2017 · 5 comments
Open

Handle missing scheme #24

ppvg opened this issue Nov 29, 2017 · 5 comments

Comments

@ppvg
Copy link

ppvg commented Nov 29, 2017

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?

@o3LL
Copy link
Contributor

o3LL commented Nov 29, 2017

@ppvg
Copy link
Author

ppvg commented Nov 29, 2017

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.

@o3LL
Copy link
Contributor

o3LL commented Nov 29, 2017

Yes, using https://github.com/epoberezkin/ajv#formats !

@dospunk
Copy link

dospunk commented Nov 30, 2017

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.

@o3LL
Copy link
Contributor

o3LL commented Nov 30, 2017

Send a PR @dospunk !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants