Fixed module library download links

This commit is contained in:
Luis Calvo 2021-02-15 12:55:35 +01:00
parent 2a7ba5fbe0
commit 514b3fca09
1 changed files with 12 additions and 1 deletions

View File

@ -409,7 +409,7 @@ function print_excerpt(id_div, response) {
category_names(elem.categories) +
"</span></p>" +
updated +
elem.content.rendered +
format_download_link(elem.content.rendered) +
'<div class="view_web"><a href="' +
elem.link +
'" target="_blank"><button class="sub next">' +
@ -516,3 +516,14 @@ function show_error_msg(selector, message_error) {
$(selector).append("<div id='empty_result'>" + message_error + "</div>");
}
}
function format_download_link(html) {
const regex = /href="(?!\bhttps?:\/\/\b)(?!pandorafms.com)(.*)"/gm;
var str = html;
const subst = `href="https://pandorafms.com$1"`;
// The substituted value will be contained in the result variable
const result = str.replace(regex, subst);
return result;
}