From: Jason Woofenden Date: Mon, 17 Nov 2008 10:00:39 +0000 (-0500) Subject: format_url() now adds http:// if there's no : X-Git-Url: https://jasonwoof.com/gitweb/?p=wfpl.git;a=commitdiff_plain;h=5b007cbcf532a8efe7fe40bc6d7f5ce4bb708985 format_url() now adds http:// if there's no : --- diff --git a/format.php b/format.php index f93d47f..7acdde3 100644 --- a/format.php +++ b/format.php @@ -146,8 +146,14 @@ function format_email($str) { } function format_url($str) { - # FIXME - return format_oneline($str); + # FIXME check for TLD? encode special chars? + $str = trim(format_oneline($str)); + if($str !== '') { + if(strpos($str, ':') === false) { + $str = 'http://' . $str; + } + } + return $str; } function format_money($str, $display_cents = true) {