Add check for Forensics Wiki URLs

feature-extract-files
Cynser 2018-10-11 17:27:51 +01:00
parent d957198fd6
commit 98d861a639
1 changed files with 4 additions and 2 deletions

View File

@ -131,14 +131,16 @@ class HTMLOperation {
*/ */
function titleFromWikiLink(url) { function titleFromWikiLink(url) {
const splitURL = url.split("/"); const splitURL = url.split("/");
if (splitURL.indexOf("wikipedia.org") < 0) { if (splitURL.indexOf("wikipedia.org") < 0 && splitURL.indexOf("forensicswiki.org") < 0) {
// Not a wiki link, return full URL // Not a wiki link, return full URL
return `<a href='${url}' target='_blank'>More Information<i class='material-icons inline-icon'>open_in_new</i></a>`; return `<a href='${url}' target='_blank'>More Information<i class='material-icons inline-icon'>open_in_new</i></a>`;
} }
const wikiName = splitURL.indexOf("forensicswiki.org") < 0 ? "Wikipedia" : "Forensics Wiki";
const pageTitle = decodeURIComponent(splitURL[splitURL.length - 1]) const pageTitle = decodeURIComponent(splitURL[splitURL.length - 1])
.replace(/_/g, " "); .replace(/_/g, " ");
return `<a href='${url}' target='_blank'>${pageTitle}<i class='material-icons inline-icon'>open_in_new</i></a> on Wikipedia`; return `<a href='${url}' target='_blank'>${pageTitle}<i class='material-icons inline-icon'>open_in_new</i></a> on ${wikiName}`;
} }
export default HTMLOperation; export default HTMLOperation;