]> git.immae.eu Git - github/wallabag/wallabag.git/blobdiff - src/Wallabag/CoreBundle/Twig/WallabagExtension.php
Twig: add removeSchemeAndWww filter
[github/wallabag/wallabag.git] / src / Wallabag / CoreBundle / Twig / WallabagExtension.php
index 351172c460f2fc24ba76c37e85e76b14ac958c57..8992117e62baef07228a517238ca44aa06ddf2e6 100644 (file)
@@ -28,6 +28,7 @@ class WallabagExtension extends \Twig_Extension implements \Twig_Extension_Globa
     {
         return [
             new \Twig_SimpleFilter('removeWww', [$this, 'removeWww']),
+            new \Twig_SimpleFilter('removeSchemeAndWww', [$this, 'removeSchemeAndWww']),
         ];
     }
 
@@ -45,6 +46,13 @@ class WallabagExtension extends \Twig_Extension implements \Twig_Extension_Globa
         return preg_replace('/^www\./i', '', $url);
     }
 
+    public function removeSchemeAndWww($url)
+    {
+        return $this->removeWww(
+            preg_replace('@^https?://@i', '', $url)
+        );
+    }
+
     /**
      * Return number of entries depending of the type (unread, archive, starred or all).
      *