Skip to content
This repository has been archived by the owner on Apr 11, 2024. It is now read-only.

Commit

Permalink
Protocol relative url support for build url helper
Browse files Browse the repository at this point in the history
  • Loading branch information
andreasnij authored and bsweeney committed Sep 25, 2015
1 parent be53f58 commit a2d0698
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/Helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,11 @@ public static function build_url($protocol, $host, $base_path, $url)
return $ret;
}

//remote urls with backslash in html/css are not really correct, but lets be genereous
if ($url[0] === '/' || $url[0] === '\\') {
// Protocol relative urls (e.g. "//example.org/style.css")
if (strpos($url, '//') === 0) {
$ret .= substr($url, 2);
//remote urls with backslash in html/css are not really correct, but lets be genereous
} elseif ($url[0] === '/' || $url[0] === '\\') {
// Absolute path
$ret .= $host . $url;
} else {
Expand Down

0 comments on commit a2d0698

Please sign in to comment.