Comment puis-je ajouter http://
à une URL si elle n'inclut pas déjà un protocole (par ex. http://
, https://
o ftp://
) ?
Exemple :
addhttp("google.com"); // http://google.com
addhttp("www.google.com"); // http://www.google.com
addhttp("google.com"); // http://google.com
addhttp("ftp://google.com"); // ftp://google.com
addhttp("https://google.com"); // https://google.com
addhttp("http://google.com"); // http://google.com
addhttp("rubbish"); // http://rubbish
1 votes
Si tu l'avais fait,
mozilla.org
seul, comment saurais-tu si ça doit l'être,http
,https
oftp
?7 votes
@Anthony : il dit qu'il veut ajouter "http://" s'il n'y a pas d'autre protocole.
3 votes
@Anthony Mais lorsque l'utilisateur tape l'url sans http:// ou autre, vous vous attendez à ce que ce soit ftp:// ou autre ?