From ce0883330306ccb9bd50aef4d7963351284bd698 Mon Sep 17 00:00:00 2001 From: millette Date: Fri, 28 Nov 2008 16:01:14 -0500 Subject: shorten urls for posts > 140 chars only, from anywhere. Only show long urls in title attributes for links we shortened ourselves. darcs-hash:20081128210114-099f7-4e4cde0a983c2ac6d41efb59b46cb7dbf45dc7a6.gz --- lib/util.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'lib') diff --git a/lib/util.php b/lib/util.php index b14d121e6..c3d11b074 100644 --- a/lib/util.php +++ b/lib/util.php @@ -837,10 +837,10 @@ function common_longurl2($uri) { function common_shorten_links($text) { if (mb_strlen($text) <= 140) return $text; + static $cache = array(); + if (isset($cache[$text])) return $cache[$text]; // \s = not a horizontal whitespace character (since PHP 5.2.4) - // RYM this should prevent * preceded URLs from being processed but it its a char -// $r = preg_replace('@[^*](https?://[^)\]>\s]+)@e', "common_shorten_link('\\1')", $r); - return preg_replace('@https?://[^)\]>\s]+@e', "common_shorten_link('\\0')", $text); + return $cache[$text] = preg_replace('@https?://[^)\]>\s]+@e', "common_shorten_link('\\0')", $text); } function common_shorten_link($long_url) { -- cgit v1.2.3-54-g00ecf