From: Christian Weiske Date: Mon, 14 Apr 2014 16:25:18 +0000 (+0200) Subject: automatically add protocol if missing X-Git-Tag: v0.1.0~16 X-Git-Url: https://git.cweiske.de/phancap.git/commitdiff_plain/8925bb89e4ee91f9503f574fd540c2d9fe53a6d2?ds=sidebyside automatically add protocol if missing --- diff --git a/src/phancap/Options.php b/src/phancap/Options.php index 6aaa49f..c1a9b09 100644 --- a/src/phancap/Options.php +++ b/src/phancap/Options.php @@ -252,7 +252,10 @@ class Options throw new \InvalidArgumentException('Invalid URL'); } if (!isset($parts['scheme'])) { - throw new \InvalidArgumentException('URL scheme missing'); + $url = 'http://' . $url; + $parts = parse_url($url); + } else if ($parts['scheme'] != 'http' && $parts['scheme'] != 'https') { + throw new \InvalidArgumentException('Unsupported protocol'); } if (!isset($parts['host'])) { throw new \InvalidArgumentException('URL host missing');