-
Notifications
You must be signed in to change notification settings - Fork 12
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
URL with without https:// fails #34
Comments
Relevant test: Line 21 in a40df5c
|
Sadly only 56.6% of websites use HTTPS: https://w3techs.com/technologies/details/ce-httpsdefault However most of the top sites use HTTPS: https://transparencyreport.google.com/https/overview The last thing we want is a person being blocked from adding a link to the @dwyl app because it does not start with |
@nelsonic > Enum.any?([:scheme, :authority, :host], &Map.get(URI.parse(url), &1))
> u = URI.parse("www.test.com")
%URI{
scheme: nil,
userinfo: nil,
host: nil,
port: nil,
path: "://www.test.com",
query: nil,
fragment: nil
}
> Enum.any?([:scheme, :authority, :host], &Map.get(u,&1))
false
##
>u = URI.parse("://www.test.com")
%URI{
scheme: nil,
userinfo: nil,
host: nil,
port: nil,
path: "www.test.com",
query: nil,
fragment: nil
}
>Enum.any?([:scheme, :authority, :host], &Map.get(u,&1))
false
##
>u = URI.parse("ftp://www.test.com")
%URI{
scheme: "ftp",
authority: "www.test.com",
userinfo: nil,
host: "www.test.com",
port: 21,
path: nil,
query: nil,
fragment: nil
}
>Enum.any?([:scheme, :authority, :host], &Map.get(u,&1))
true
> u = URI.parse("https://www.test.com?p=1")
%URI{
scheme: "https",
authority: "www.test.com",
userinfo: nil,
host: "www.test.com",
port: 443,
path: nil,
query: "p=1",
fragment: nil
}
> Enum.any?([:scheme, :authority, :host], &Map.get(u,&1))
true
|
We are using
Fields.url
in a project and a user is attempting to insert a url:To the user, this looks like a perfectly valid URL,
sadly our regex in #16 rejects a url without a protocol.
Question:
Do we want to allow urls without a protocol (i.e. be user-friendly)
or do we want to be strict and continue rejecting them?
The text was updated successfully, but these errors were encountered: