Improvements and fixes for link matching
parent
fa268d5f94
commit
472c05317f
|
@ -347,7 +347,7 @@ async function main(url, tabId) {
|
|||
// Get article name from the end of the URL;
|
||||
// We can't just take the last part of the path due to subpages;
|
||||
// Instead, we take everything after the wiki's base URL + content path
|
||||
let article = decodeURIComponent(url.split(site['origin_base_url'] + site['origin_content_path'])[1]);
|
||||
let article = decodeURIComponent(url.split(site['origin_base_url'] + site['origin_content_path'])[1] || '');
|
||||
// Set up URL to redirect user to based on wiki platform
|
||||
let newURL = '';
|
||||
if (article) {
|
||||
|
|
|
@ -285,7 +285,7 @@ function main() {
|
|||
// Get article name from the end of the URL;
|
||||
// We can't just take the last part of the path due to subpages;
|
||||
// Instead, we take everything after the wiki's base URL + content path:
|
||||
let article = decodeURIComponent(String(origin).split(site['origin_content_path'])[1]);
|
||||
let article = decodeURIComponent(String(origin).split(site['origin_base_url'] + site['origin_content_path'])[1] || '');
|
||||
// Set up URL to redirect user to based on wiki platform:
|
||||
let newURL = '';
|
||||
if (article) {
|
||||
|
|
|
@ -195,7 +195,7 @@ function escapeRegex(string) {
|
|||
|
||||
function replaceSearchResults(searchResultContainer, site, link) {
|
||||
// Build new URL:
|
||||
let article = decodeURIComponent(link.split(site['origin_content_path'])[1]?.split('#')[0].split('?')[0].split('&')[0]);
|
||||
let article = decodeURIComponent((link.split(site['origin_base_url'] + site['origin_content_path'])[1] || '').split('#')[0].split('?')[0].split('&')[0]);
|
||||
let newURL = '';
|
||||
if (article) {
|
||||
// Check if main page
|
||||
|
@ -423,7 +423,8 @@ function filterSearchResults(searchResults, searchEngine, storage) {
|
|||
if (crossLanguageSetting === 'on') {
|
||||
matchingSites = sites.filter(el => link.replace(/.*https?:\/\//, '').startsWith(el.origin_base_url));
|
||||
} else {
|
||||
matchingSites = sites.filter(el => link.replace(/.*https?:\/\//, '').startsWith(el.origin_base_url + el.origin_content_path));
|
||||
matchingSites = sites.filter(el => link.replace(/.*https?:\/\//, '') === (el.origin_base_url));
|
||||
matchingSites = matchingSites.concat(sites.filter(el => link.replace(/.*https?:\/\//, '').startsWith(el.origin_base_url + el.origin_content_path)));
|
||||
}
|
||||
if (matchingSites.length > 0) {
|
||||
// Select match with longest base URL
|
||||
|
|
Loading…
Reference in New Issue