diff --git a/client/dcwebui.js b/client/dcwebui.js index 2bf0aed..f4751de 100644 --- a/client/dcwebui.js +++ b/client/dcwebui.js @@ -50,9 +50,22 @@ var fmtBytes = function(b) { return parseFloat((bytes / Math.pow(k, i)).toFixed(3)) + sizes[i]; }; + +var urldesc = function(s) { + return decodeURIComponent(s.replace(/\+/g, " ")); +} + var linkify = function(str) { - return str.replace( - /(https?:\/\/[^\s<]+)/g, "$1" + // n.b. str is already hesced + return (str + .replace( + /(https?:\/\/[^\s<]+)/g, + "$1" + ) + .replace( + /magnet:\?.+dn=([^\< ]+)/g, + function(match, m1) { return "[MAGNET] " + urldesc(m1) + ""; } + ) ); };