diff options
author | nodiscc <nodiscc@gmail.com> | 2015-03-04 19:52:24 +0100 |
---|---|---|
committer | nodiscc <nodiscc@gmail.com> | 2015-03-04 20:11:39 +0100 |
commit | ad2a397c66a3da8061564602b43db6f2002f0064 (patch) | |
tree | 4ddf581755bd8bc41f68006adc9c49b12da699c6 | |
parent | bc1ef5b94a711a0db249f1773db9b3ca1da31c6c (diff) | |
download | Shaarli-ad2a397c66a3da8061564602b43db6f2002f0064.tar.gz Shaarli-ad2a397c66a3da8061564602b43db6f2002f0064.tar.zst Shaarli-ad2a397c66a3da8061564602b43db6f2002f0064.zip |
cleanup: refactor annoying URL patterns in a single loop
* fixes https://github.com/shaarli/Shaarli/issues/133
-rw-r--r-- | index.php | 15 |
1 files changed, 6 insertions, 9 deletions
@@ -1642,15 +1642,12 @@ function renderPage() | |||
1642 | { | 1642 | { |
1643 | $url=$_GET['post']; | 1643 | $url=$_GET['post']; |
1644 | 1644 | ||
1645 | // We remove the annoying parameters added by FeedBurner and GoogleFeedProxy (?utm_source=...) | 1645 | // We remove the annoying parameters added by FeedBurner, GoogleFeedProxy, Facebook... |
1646 | $i=strpos($url,'&utm_source='); if ($i!==false) $url=substr($url,0,$i); | 1646 | $annoyingpatterns = array('&utm_source=', '?utm_source=', '#xtor=RSS-', '?fb_', '?__scoop', '#tk.rss_all?', '?utm_campaign=', '?utm_medium='); |
1647 | $i=strpos($url,'?utm_source='); if ($i!==false) $url=substr($url,0,$i); | 1647 | foreach($annoyingpatterns as $pattern) |
1648 | $i=strpos($url,'#xtor=RSS-'); if ($i!==false) $url=substr($url,0,$i); | 1648 | { |
1649 | $i=strpos($url,'?fb_'); if ($i!==false) $url=substr($url,0,$i); | 1649 | $i=strpos($url,$pattern); if ($i!==false) $url=substr($url,0,$i); |
1650 | $i=strpos($url,'?__scoop'); if ($i!==false) $url=substr($url,0,$i); | 1650 | } |
1651 | $i=strpos($url,'#tk.rss_all?'); if ($i!==false) $url=substr($url,0,$i); | ||
1652 | $i=strpos($url,'?utm_campaign='); if ($i!==false) $url=substr($url,0,$i); | ||
1653 | $i=strpos($url,'?utm_medium='); if ($i!==false) $url=substr($url,0,$i); | ||
1654 | 1651 | ||
1655 | $link_is_new = false; | 1652 | $link_is_new = false; |
1656 | $link = $LINKSDB->getLinkFromUrl($url); // Check if URL is not already in database (in this case, we will edit the existing link) | 1653 | $link = $LINKSDB->getLinkFromUrl($url); // Check if URL is not already in database (in this case, we will edit the existing link) |