From a2d069805e1eb2e0fdd8db1a0b877f3ea4f04126 Mon Sep 17 00:00:00 2001 From: Andreas Date: Fri, 25 Sep 2015 15:41:44 +0200 Subject: [PATCH] Protocol relative url support for build url helper Closes #1026 --- src/Helpers.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/Helpers.php b/src/Helpers.php index 6dac3916b..996a99c4a 100644 --- a/src/Helpers.php +++ b/src/Helpers.php @@ -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 {