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 f7f3605d103b999cfee3a314fdd4e48a0922958d..1da91cb390775b5f751efada1d8abb6f00dd8a81 100644 (file)
@@ -16,8 +16,14 @@ class Validator
         }
 
         if (!isset($parts['host'])) {
         }
 
         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;
         }
 
         return $url;