admin: offer domains extracted from roots among "main address" options
Massimo Melina committed
Apr 15, 2024 at 22:03 UTC
6da5abbe99df9267deb3f58c8ef3114aee1e073b
1 file changed
+5
-2
admin/src/FileForm.ts
+5
-2
@@ -9,7 +9,7 @@ import { apiCall, UseApi } from './api'
9
import {
10
basename, defaultPerms, formatBytes, formatTimestamp, isEqualLax, isWhoObject, newDialog, objSameKeys,
11
onlyTruthy, prefix, VfsPerms, wantArray, Who, WhoObject, matches, HTTP_MESSAGES, xlate, md, Callback,
12
- useRequestRender
12
+ useRequestRender, splitAt
13
} from './misc'
14
import { Btn, IconBtn, LinkBtn, modifiedProps, useBreakpoint, wikiLink } from './mui'
15
import { reloadVfs, VfsNode } from './VfsPage'
@@ -373,8 +373,11 @@ function LinkField({ value, statusApi }: LinkFieldProps) {
373
export async function changeBaseUrl() {
374
return new Promise(async resolve => {
375
const res = await apiCall('get_status')
376
- const { base_url } = await apiCall('get_config', { only: ['base_url'] })
376
+ const { base_url, roots } = await apiCall('get_config', { only: ['base_url', 'roots'] })
377
const urls: string[] = res.urls.https || res.urls.http
378
+ const domainsFromRoots = Object.keys(roots).map(x => x.split('|')).flat().filter(x => !/[*?]/.test(x))
379
+ const proto = splitAt('//', urls[0])[0] + '//'
380
+ urls.push(...domainsFromRoots.map(x => proto + x))
381
const { close } = newDialog({
382
title: "Main address",
383
Content() {