simplified and improved replace patterns
This commit is contained in:
parent
54c8a70f8e
commit
25ab48951f
1 changed files with 3 additions and 3 deletions
|
@ -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,"<a href='$1'>$1</a>");
|
||||
}
|
||||
|
||||
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<a href='http://twitter.com/$3'>$3</a>");
|
||||
return text.replace(hash, "$1$2<a href='http://search.twitter.com/search?q=%23$3'>$3</a>");
|
||||
}
|
||||
|
|
Reference in a new issue