]> git.immae.eu Git - github/shaarli/Shaarli.git/blobdiff - application/Url.php
Fixes #410 - Retrieve title fails in multiple cases
[github/shaarli/Shaarli.git] / application / Url.php
old mode 100644 (file)
new mode 100755 (executable)
index d80c9c5..a4ac2e7
@@ -118,7 +118,7 @@ class Url
      */
     public function __construct($url)
     {
-        $this->parts = parse_url($url);
+        $this->parts = parse_url(trim($url));
 
         if (!empty($url) && empty($this->parts['scheme'])) {
             $this->parts['scheme'] = 'http';
@@ -201,4 +201,13 @@ class Url
         }
         return $this->parts['scheme'];
     }
+
+    /**
+     * Test if the Url is an HTTP one.
+     *
+     * @return true is HTTP, false otherwise.
+     */
+    public function isHttp() {
+        return strpos(strtolower($this->parts['scheme']), 'http') !== false;
+    }
 }