Accounting for plus signs in Fextra article names + encoding article titles
parent
d30b8434de
commit
f711d6f945
|
@ -310,6 +310,15 @@ async function main(url, tabId) {
|
||||||
// Replace underscores with spaces as that performs better in search
|
// Replace underscores with spaces as that performs better in search
|
||||||
destinationArticle = destinationArticle.replaceAll('_', ' ');
|
destinationArticle = destinationArticle.replaceAll('_', ' ');
|
||||||
|
|
||||||
|
// If a Fextralife wiki, replace plus signs with spaces
|
||||||
|
// When there are multiple plus signs together, this regex will only replace only the first
|
||||||
|
if (site['origin_base_url'].includes('.wiki.fextralife.com')) {
|
||||||
|
destinationArticle = destinationArticle.replace(/(?<!\+)\+/g, ' ');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Encode article
|
||||||
|
destinationArticle = encodeURIComponent(destinationArticle);
|
||||||
|
|
||||||
let searchParams = '';
|
let searchParams = '';
|
||||||
switch (site['destination_platform']) {
|
switch (site['destination_platform']) {
|
||||||
case 'mediawiki':
|
case 'mediawiki':
|
||||||
|
|
|
@ -434,6 +434,15 @@ function main() {
|
||||||
// Replace underscores with spaces as that performs better in search
|
// Replace underscores with spaces as that performs better in search
|
||||||
destinationArticle = destinationArticle.replaceAll('_', ' ');
|
destinationArticle = destinationArticle.replaceAll('_', ' ');
|
||||||
|
|
||||||
|
// If a Fextralife wiki, replace plus signs with spaces
|
||||||
|
// When there are multiple plus signs together, this regex will only replace only the first
|
||||||
|
if (site['origin_base_url'].includes('.wiki.fextralife.com')) {
|
||||||
|
destinationArticle = destinationArticle.replace(/(?<!\+)\+/g, ' ');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Encode article
|
||||||
|
destinationArticle = encodeURIComponent(destinationArticle);
|
||||||
|
|
||||||
let searchParams = '';
|
let searchParams = '';
|
||||||
switch (site['destination_platform']) {
|
switch (site['destination_platform']) {
|
||||||
case 'mediawiki':
|
case 'mediawiki':
|
||||||
|
@ -443,8 +452,7 @@ function main() {
|
||||||
searchParams = 'start?do=search&q=' + destinationArticle;
|
searchParams = 'start?do=search&q=' + destinationArticle;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
newURL = 'https://' + site["destination_base_url"] + site["destination_search_path"] + searchParams.replaceAll('+', '_');
|
newURL = 'https://' + site["destination_base_url"] + site["destination_search_path"] + searchParams;
|
||||||
// We replace plus signs with underscores since Fextralife uses pluses instead of spaces/underscores
|
|
||||||
} else {
|
} else {
|
||||||
newURL = 'https://' + site["destination_base_url"];
|
newURL = 'https://' + site["destination_base_url"];
|
||||||
}
|
}
|
||||||
|
|
|
@ -213,6 +213,15 @@ function replaceSearchResults(searchResultContainer, site, link) {
|
||||||
// Replace underscores with spaces as that performs better in search
|
// Replace underscores with spaces as that performs better in search
|
||||||
destinationArticle = destinationArticle.replaceAll('_', ' ');
|
destinationArticle = destinationArticle.replaceAll('_', ' ');
|
||||||
|
|
||||||
|
// If a Fextralife wiki, replace plus signs with spaces
|
||||||
|
// When there are multiple plus signs together, this regex will only replace only the first
|
||||||
|
if (site['origin_base_url'].includes('.wiki.fextralife.com')) {
|
||||||
|
destinationArticle = destinationArticle.replace(/(?<!\+)\+/g, ' ');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Encode article
|
||||||
|
destinationArticle = encodeURIComponent(destinationArticle);
|
||||||
|
|
||||||
let searchParams = '';
|
let searchParams = '';
|
||||||
switch (site['destination_platform']) {
|
switch (site['destination_platform']) {
|
||||||
case 'mediawiki':
|
case 'mediawiki':
|
||||||
|
|
Loading…
Reference in New Issue