better URL completion
authorChristian Weiske <cweiske@cweiske.de>
Tue, 6 Sep 2016 22:27:19 +0000 (00:27 +0200)
committerChristian Weiske <cweiske@cweiske.de>
Tue, 6 Sep 2016 22:27:19 +0000 (00:27 +0200)
src/shpub/Validator.php

index f7f3605..1da91cb 100644 (file)
@@ -16,8 +16,14 @@ class Validator
         }
 
         if (!isset($parts['host'])) {
-            Log::err('Invalid URL: No host in ' . $helpName);
-            return false;
+            if (count($parts) == 1 && isset($parts['path'])) {
+                //parse_url('example.org') puts 'example.org' in the path
+                // but this is common, so we fix it.
+                $url = 'http://' . $parts['path'];
+            } else {
+                Log::err('Invalid URL: No host in ' . $helpName);
+                return false;
+            }
         }
 
         return $url;