From 8925bb89e4ee91f9503f574fd540c2d9fe53a6d2 Mon Sep 17 00:00:00 2001 From: Christian Weiske Date: Mon, 14 Apr 2014 18:25:18 +0200 Subject: [PATCH] automatically add protocol if missing --- src/phancap/Options.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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'); -- 2.30.2