-
-
Notifications
You must be signed in to change notification settings - Fork 290
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Throw error if long URLs are provided without schema #1715
Comments
This is a bug. Option one is how it should be working. I even remember having to tweak this to support deeplinks, some years ago. Perhaps that was what broke this. |
I have been re-considering this for a couple reasons.
The first problem was caused by me. I have had to rewrite many tests, but such is life. It's done now. Regarding the second problem, I have decided to still go with it because a) most of the people use shlink-web-client, which already validates URLs, and b) the resulting short URLs when the schema is not provided are completely broken, so I very much doubt anyone was actually relying on this behavior. That said, since Shlink has to support different types of URIs (including deeplinks and such), I have decided to go with a simplistic approach, which is just validating that provided URL has a schema of any type. So values like |
Summary
When creating short codes with the REST API, e.g.
createShortUrl
, long URLs without a schema are allowed and Shlink redirects them to the default domain where the longUrl is appended to the URI. Same is true for the newdeviceLongUrl.[android|ios|desktop]
request properties too.For example, If the value
bbc.co.uk
is given for longUrl, Shlink redirects tohttp://<default_domain>/bbc.co.uk
instead ofhttp(s)://bbc.co.uk
.Example request:
There are two solutions to this request:
longUrl
is given without a schema. Shlink web UI has validation in the form so this implementation would match that behaviourhttp://
in this situation and use this in the responseIf it were me, I'd probably go with option 1 on the basis if you're creating short-url's via REST API then you should a) know what a schema is and why it's important to specify and b) can handle errors in code. Plus it'll follow the functionality of the web UI.
Although option 2 allows for an easier user experience.
The text was updated successfully, but these errors were encountered: