Change how WikiTree authcode is retrieved fromthe URL

This commit is contained in:
Przemek Więch
2023-09-11 23:29:43 +02:00
parent cb6b877734
commit 4049b322e7

View File

@@ -114,16 +114,18 @@ interface Arguments {
config: Config; config: Config;
} }
function getParamFromSearch(name: string, search: queryString.ParsedQuery<string>) {
const value = search[name];
return typeof value === 'string' ? value : undefined;
}
/** /**
* Retrieve arguments passed into the application through the URL and uploaded * Retrieve arguments passed into the application through the URL and uploaded
* data. * data.
*/ */
function getArguments(location: H.Location<any>): Arguments { function getArguments(location: H.Location<any>): Arguments {
const search = queryString.parse(location.search); const search = queryString.parse(location.search);
const getParam = (name: string) => { const getParam = (name: string) => getParamFromSearch(name, search);
const value = search[name];
return typeof value === 'string' ? value : undefined;
};
const view = getParam('view'); const view = getParam('view');
const chartTypes = new Map<string | undefined, ChartType>([ const chartTypes = new Map<string | undefined, ChartType>([
@@ -136,9 +138,10 @@ function getArguments(location: H.Location<any>): Arguments {
const embedded = getParam('embedded') === 'true'; // False by default. const embedded = getParam('embedded') === 'true'; // False by default.
var sourceSpec: DataSourceSpec | undefined = undefined; var sourceSpec: DataSourceSpec | undefined = undefined;
if (getParam('source') === 'wikitree') { if (getParam('source') === 'wikitree') {
const windowSearch = queryString.parse(window.location.search);
sourceSpec = { sourceSpec = {
source: DataSourceEnum.WIKITREE, source: DataSourceEnum.WIKITREE,
authcode: getParam('authcode'), authcode: getParam('authcode') || getParamFromSearch('authcode', windowSearch),
}; };
} else if (hash) { } else if (hash) {
sourceSpec = { sourceSpec = {