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 6aaa49f..c1a9b09 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');