automatically add protocol if missing
authorChristian Weiske <cweiske@cweiske.de>
Mon, 14 Apr 2014 16:25:18 +0000 (18:25 +0200)
committerChristian Weiske <cweiske@cweiske.de>
Mon, 14 Apr 2014 16:25:18 +0000 (18:25 +0200)
src/phancap/Options.php

index 6aaa49f6131424187fd5ebf7d9119858c4691aa2..c1a9b09a94631600cb79682fd7a83cdbd6db792e 100644 (file)
@@ -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');