summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authormillette <millette@controlyourself.ca>2008-11-28 16:01:14 -0500
committermillette <millette@controlyourself.ca>2008-11-28 16:01:14 -0500
commitce0883330306ccb9bd50aef4d7963351284bd698 (patch)
tree48797bd1dac83f1dd08e39a77f11540f53bed249 /lib
parent4fca9960cd5388ff2a12472b956e2504a5af7549 (diff)
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
Diffstat (limited to 'lib')
-rw-r--r--lib/util.php6
1 files changed, 3 insertions, 3 deletions
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) {