Merge master

This commit is contained in:
Pieter Vander Vennet 2022-06-19 18:23:43 +02:00
commit 470e9acc64
66 changed files with 10798 additions and 414 deletions

View file

@ -8,7 +8,7 @@ import {Utils} from "../../Utils";
export class QueryParameters {
static defaults = {}
static documentation = {}
static documentation: Map<string, string> = new Map<string, string>()
private static order: string [] = ["layout", "test", "z", "lat", "lon"];
private static _wasInitialized: Set<string> = new Set()
private static knownSources = {};
@ -18,7 +18,7 @@ export class QueryParameters {
if (!this.initialized) {
this.init();
}
QueryParameters.documentation[key] = documentation;
QueryParameters.documentation.set(key, documentation);
if (deflt !== undefined) {
QueryParameters.defaults[key] = deflt;
}

View file

@ -121,13 +121,14 @@ export default class Wikipedia {
* @param searchTerm
*/
public async searchViaIndex(searchTerm: string): Promise<{ title: string, snippet: string, url: string } []> {
const url = `${this.backend}/w/index.php?search=${encodeURIComponent(searchTerm)}`
const url = `${this.backend}/w/index.php?search=${encodeURIComponent(searchTerm)}&ns0=1`
const result = await Utils.downloadAdvanced(url);
if(result["redirect"] ){
const targetUrl = result["redirect"]
// This is an exact match
return [{
title: this.extractPageName(result["redirect"]).trim(),
url: result["redirect"],
title: this.extractPageName(targetUrl)?.trim(),
url: targetUrl,
snippet: ""
}]
}