client: clickable magnet links
This commit is contained in:
parent
3c1db1266e
commit
56ced01e97
@ -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, "<a target='_blank' rel=\"noreferrer\" href=\"$1\">$1</a>"
|
||||
// n.b. str is already hesced
|
||||
return (str
|
||||
.replace(
|
||||
/(https?:\/\/[^\s<]+)/g,
|
||||
"<a target='_blank' rel=\"noreferrer\" href=\"$1\">$1</a>"
|
||||
)
|
||||
.replace(
|
||||
/magnet:\?.+dn=([^\< ]+)/g,
|
||||
function(match, m1) { return "<a href=\"" + match + "\">[MAGNET] " + urldesc(m1) + "</a>"; }
|
||||
)
|
||||
);
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user