[TASK] Improve link parsing function 75/25375/3
authorNicole Cordes <cordes@cps-it.de>
Wed, 13 Nov 2013 13:32:03 +0000 (14:32 +0100)
committerNicole Cordes <typo3@cordes.co>
Wed, 13 Nov 2013 14:04:00 +0000 (15:04 +0100)
Releases: 1.1
Change-Id: Ib896ad20bea4ee9f287c719266b7631009eb2a14
Reviewed-on: https://review.typo3.org/25375
Reviewed-by: Nicole Cordes
Tested-by: Nicole Cordes
Classes/UserFunction/user_wttwitter_userfunction.php

index f921e16..563be71 100644 (file)
@@ -73,9 +73,7 @@ class user_wttwitteruserfunction {
                $string = $this->cObj->getCurrentVal(); // get date from typoscript
 
                // 1. rewrite URL with typolink
-               $string = str_replace('http://www.', 'www.', $string); // replace all link beginnings to http://www (part 1)
-               $string = str_replace('www.', 'http://www.', $string); // replace all link beginnings to http://www (part 2)
-               preg_match_all('/([\w]+:\/\/[\w-?&;#~=\.\/\@]+[\w\/])/i', $string, $arr_result); // get all links of the string
+               preg_match_all('/(https?:\/\/|www\.)\S*/i', $string, $arr_result); // get all links of the string
                foreach ((array)$arr_result[0] as $url) { // one loop for every link in the string
                        if (!empty($url)) { // if there is a URL
                                $typolinkconf = array('parameter' => $url); // typolink configuration