properly handle restrictBaseUrl config option, fixes #128

This commit is contained in:
Aine 2024-11-07 10:34:06 +02:00
parent c698f57395
commit 6faebaf9df
No known key found for this signature in database
GPG key ID: 34969C908CCA2804

View file

@ -43,6 +43,13 @@ export const LoadConfig = (context: Config): Config => {
// below we try to calculate "final" config, which will contain values from context and already set values in storage
// because LoadConfig could be called multiple times to get config from different sources
let finalRestrictBaseUrl: string | string[] = "";
try {
finalRestrictBaseUrl = JSON.parse(storage.getItem("restrict_base_url") || "");
if (Array.isArray(finalRestrictBaseUrl) && finalRestrictBaseUrl.length == 1) {
finalRestrictBaseUrl = finalRestrictBaseUrl[0];
}
} catch (e) {}
let finalAsManagedUsers: string[] = [];
try {
finalAsManagedUsers = JSON.parse(storage.getItem("as_managed_users") || "");
@ -54,7 +61,7 @@ export const LoadConfig = (context: Config): Config => {
} catch (e) {}
return {
restrictBaseUrl: storage.getItem("restrict_base_url") || "",
restrictBaseUrl: finalRestrictBaseUrl,
asManagedUsers: finalAsManagedUsers,
supportURL: storage.getItem("support_url") || "",
menu: finalMenu,