Skip to content

Commit

Permalink
Data formatter : url
Browse files Browse the repository at this point in the history
Signed-off-by: daverner <[email protected]>
  • Loading branch information
daverner committed Oct 8, 2020
1 parent 2bf4f0d commit 271adb6
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions Services/DataFormatterHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,14 @@ public function format( $data, $format, $pattern = null )
return $this->human_filesize( $data, $pattern );
case "datetime":
return $this->toDateTime( $data );
case "url":
$url = $data;
// Check if protocol is in $data
if( !preg_match( '#^http(?:s)?://#', $data ) )
{
$url = "http://". $data;
}
return $url;
}

throw new DataFormatterException( "Unknown format name : $format" );
Expand Down

0 comments on commit 271adb6

Please sign in to comment.