1

So,

  1. web site have a user profile
  2. user can edit own profile
  3. profile data have "site" data field
  4. user can enter some site url and after that this url will shown in profile like a link

if user enter site with protocol (https://facebook.com ) there is no problem and it goes to https://facebook.com

but if user enter something like this facebook.com it will be internal link and goes to https://my.site.com/facebook.com

how can i avoid this situation?

Vladimir Gordienko
  • 3,260
  • 3
  • 18
  • 25
  • May be ths will help you http://stackoverflow.com/questions/2762061/how-to-add-http-if-its-not-exists-in-the-url – senK Sep 09 '14 at 07:30

2 Answers2

2

Check if there is :// in the entered data. If not then add http://

Zeusarm
  • 1,038
  • 6
  • 14
0

Unless you need to do some advanced checks, you can just check it when they add their url / site - if the "site" value does not start with http:// or https://, just add it in front before you save it.

Daniel Andre
  • 303
  • 1
  • 7