문제

Sorry if this question has been answered elsewhere, but I've spent awhile looking with no luck.

In my web app, I ask users to specify urls to their blogs. However, they don't always put "http://" at the beginning of these urls. Elsewhere on the site, when I link to these urls, the browser interprets them as relative urls. e.g. if the user writes bobsblog.wordpress.com, the link goes to http://www.mydomain.com/bobsblog.wordpress.com.

One solution is to pre-populate the url field with "http://".

But a nicer solution would be to parse the url and add the scheme if the user hasn't. Does rails offer a good way to do this? I looked at the function URI::parse, but it doesn't seem to offer a good way of doing that.

올바른 솔루션이 없습니다

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top