From 4049b322e75ecf4c2475778e210d66a21b6d7902 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Przemek=20Wi=C4=99ch?= Date: Mon, 11 Sep 2023 23:29:43 +0200 Subject: [PATCH] Change how WikiTree authcode is retrieved fromthe URL --- src/app.tsx | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/app.tsx b/src/app.tsx index 8c5f957..7d7b30b 100644 --- a/src/app.tsx +++ b/src/app.tsx @@ -114,16 +114,18 @@ interface Arguments { config: Config; } +function getParamFromSearch(name: string, search: queryString.ParsedQuery) { + const value = search[name]; + return typeof value === 'string' ? value : undefined; +} + /** * Retrieve arguments passed into the application through the URL and uploaded * data. */ function getArguments(location: H.Location): Arguments { const search = queryString.parse(location.search); - const getParam = (name: string) => { - const value = search[name]; - return typeof value === 'string' ? value : undefined; - }; + const getParam = (name: string) => getParamFromSearch(name, search); const view = getParam('view'); const chartTypes = new Map([ @@ -136,9 +138,10 @@ function getArguments(location: H.Location): Arguments { const embedded = getParam('embedded') === 'true'; // False by default. var sourceSpec: DataSourceSpec | undefined = undefined; if (getParam('source') === 'wikitree') { + const windowSearch = queryString.parse(window.location.search); sourceSpec = { source: DataSourceEnum.WIKITREE, - authcode: getParam('authcode'), + authcode: getParam('authcode') || getParamFromSearch('authcode', windowSearch), }; } else if (hash) { sourceSpec = {