diff options
author | Ben Klang <bklang@mojolingo.com> | 2015-03-11 22:06:34 +0300 |
---|---|---|
committer | Ben Klang <bklang@mojolingo.com> | 2015-03-26 22:57:52 +0300 |
commit | 45a68410d86f29246f35af8cb3507c4dcb79db44 (patch) | |
tree | 684a8718d7296600dd302a21836523a36bb75ca9 | |
parent | 9ad044bed76ab262878682d637cf2f5c7b29ae25 (diff) |
Allow option to truncate display of long URLs
-rw-r--r-- | src/util.js | 4 | ||||
-rw-r--r-- | src/view.js | 2 |
2 files changed, 4 insertions, 2 deletions
diff --git a/src/util.js b/src/util.js index fd866aa..bbd1622 100644 --- a/src/util.js +++ b/src/util.js @@ -520,7 +520,9 @@ Candy.Util = (function(self, $){ */ linkify: function(text) { text = text.replace(/(^|[^\/])(www\.[^\.]+\.[\S]+(\b|$))/gi, '$1http://$2'); - return text.replace(/(\b(?:(?:https?|ftp|file):\/\/)(?:\S+(?::\S*)?@)?(?:(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:1\d\d|2[01]\d|22[0-3]|[1-9]\d?)(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z\u00a1-\uffff0-9]-*)*[a-z\u00a1-\uffff0-9]+)(?:\.(?:[a-z\u00a1-\uffff0-9]-*)*[a-z\u00a1-\uffff0-9]+)*(?:\.(?:[a-z\u00a1-\uffff]{2,})))(?::\d{2,5})?(?:\/\S*)?)/gi, '<a href="$1" target="_blank">$1</a>'); + return text.replace(/(\b(?:(?:https?|ftp|file):\/\/)(?:\S+(?::\S*)?@)?(?:(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:1\d\d|2[01]\d|22[0-3]|[1-9]\d?)(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z\u00a1-\uffff0-9]-*)*[a-z\u00a1-\uffff0-9]+)(?:\.(?:[a-z\u00a1-\uffff0-9]-*)*[a-z\u00a1-\uffff0-9]+)*(?:\.(?:[a-z\u00a1-\uffff]{2,})))(?::\d{2,5})?(?:\/\S*)?)/gi, function(matched, url) { + return '<a href="' + url + '" target="_blank">' + self.crop(url, Candy.View.getOptions().crop.message.url) + '</a>'; + }); }, /** Function: escape diff --git a/src/view.js b/src/view.js index b670302..7be6b8e 100644 --- a/src/view.js +++ b/src/view.js @@ -39,7 +39,7 @@ Candy.View = (function(self, $) { assets: 'res/', messages: { limit: 2000, remove: 500 }, crop: { - message: { nickname: 15, body: 1000 }, + message: { nickname: 15, body: 1000, url: 64 }, roster: { nickname: 15 } }, enableXHTML: false |