From ce4f67d6504614502fac781174a75472d50bb312 Mon Sep 17 00:00:00 2001 From: 0xffffharry <95022881+0xffffharry@users.noreply.github.com> Date: Sun, 2 Jun 2024 21:22:20 +0800 Subject: [PATCH] fix: auto configure (#726) --- src/pages/Setup.tsx | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/pages/Setup.tsx b/src/pages/Setup.tsx index 29db76f..ab8cf89 100644 --- a/src/pages/Setup.tsx +++ b/src/pages/Setup.tsx @@ -108,11 +108,21 @@ export default () => { } onMount(() => { - const query = new URLSearchParams(location.search) + let search = location.search + + if (search.length === 0) { + const searchList = location.hash.match(/\?.*$/) + + if (searchList.length > 0 && searchList[0].length > 0) { + search = searchList[0].replace('?', '', 1) + } + } + + const query = new URLSearchParams(search) if (query.has('hostname')) { void onSubmit({ - url: `${window.location.protocol}//${query.get('hostname')}${ + url: `${query.get('http') ? 'http:' : query.get('https') ? 'https:' : window.location.protocol}//${query.get('hostname')}${ query.get('port') ? `:${query.get('port')}` : '' }`, secret: query.get('secret') ?? '',