Permalink
Browse files

Autolink copyright and make autolink more robust when passed in empty…

… non strings
  • Loading branch information...
jwheare committed Dec 15, 2009
1 parent da1f3a7 commit 5fa47d998d524640af420e98197f624538b5d2c6
Showing with 3 additions and 1 deletion.
  1. +2 −1 src/js/controllers/playlist.controller.js
  2. +1 −0 src/js/util.js
@@ -291,7 +291,8 @@ Playlist.prototype = {
this.actionsElem.hide();
},
loadCopyright: function () {
- this.copyrightElem.text(this.current.copyright || '');
+ var escapedCopyright = $('<div>').html(this.current.copyright).text();
+ this.copyrightElem.html(UTIL.autoLink(escapedCopyright) || '');
},
loadSource: function () {
if (this.current.source) {
View
@@ -42,6 +42,7 @@ var UTIL = {
// Based on http://daringfireball.net/2009/11/liberal_regex_for_matching_urls
autolink_regexp: /\b([\w-]+:\/+|www[.])[^\s()<>]+(?:\([\w\d]+\)|(?:[^.,;'">\:\s\<\>\)\]\!]|\/))/g,
autoLink: function (word) {
+ word = word || '';
return word.replace(UTIL.autolink_regexp, function (match, protocol, index, full) {
var url = match;
if (protocol == 'www.') {

0 comments on commit 5fa47d9

Please sign in to comment.