]> git.immae.eu Git - github/shaarli/Shaarli.git/blobdiff - application/Url.php
Fixes #325 - Shaarli does not recognize saved links
[github/shaarli/Shaarli.git] / application / Url.php
old mode 100644 (file)
new mode 100755 (executable)
index 23356f3..02a4395
@@ -81,6 +81,10 @@ class Url
     public function __construct($url)
     {
         $this->parts = parse_url($url);
+
+        if (!empty($url) && empty($this->parts['scheme'])) {
+            $this->parts['scheme'] = 'http';
+        }
     }
 
     /**
@@ -147,4 +151,16 @@ class Url
         $this->cleanupFragment();
         return $this->__toString();
     }
+
+    /**
+     * Get URL scheme.
+     *
+     * @return string the URL scheme or false if none is provided.
+     */
+    public function getScheme() {
+        if (!isset($this->parts['scheme'])) {
+            return false;
+        }
+        return $this->parts['scheme'];
+    }
 }