From 25ab48951f34becbf4a408eda01c392f7931259f Mon Sep 17 00:00:00 2001 From: Samuel Reis Date: Tue, 21 Sep 2010 17:19:24 +0200 Subject: [PATCH] simplified and improved replace patterns --- TwittiaCore.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/TwittiaCore.js b/TwittiaCore.js index 7ffb652..4f2380e 100644 --- a/TwittiaCore.js +++ b/TwittiaCore.js @@ -307,13 +307,13 @@ Twittia.prototype.authorizationHeader = function(method, url, params) { } function replaceURLWithHTMLLinks(text) { - var exp = /(\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_()|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/ig; + var exp = /(\b(https?|ftp|file):\/\/\S+)/ig; return text.replace(exp,"$1"); } function replaceTwitterLinks(text) { - var username = /(^|[^\/\w])(@)([-A-Z0-9+_\.ÅÖÄÜ]+[^\.,;\W])/ig; - var hash = /(^|[^\/\w])(#)([-A-Z0-9+_\.ÅÖÄÜß]+[^\.,;\W])/ig; + var username = /(^|\s)(@)(\S*)/ig; + var hash = /(^|\s)(#)(\S*)/ig; text = text.replace(username, "$1$2$3"); return text.replace(hash, "$1$2$3"); }