Handle trailing dot FQDNs for domain-specific config.json files (#25351)

pull/25359/head
Michael Telatynski 2023-05-12 13:46:49 +01:00 committed by GitHub
parent 9457af27f6
commit d7a98fe392
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 1 deletions

View File

@ -21,7 +21,13 @@ import type { IConfigOptions } from "matrix-react-sdk/src/IConfigOptions";
export async function getVectorConfig(relativeLocation = ""): Promise<IConfigOptions | undefined> {
if (relativeLocation !== "" && !relativeLocation.endsWith("/")) relativeLocation += "/";
const specificConfigPromise = getConfig(`${relativeLocation}config.${window.location.hostname}.json`);
// Handle trailing dot FQDNs
let domain = window.location.hostname.trimEnd();
if (domain[domain.length - 1] === ".") {
domain = domain.slice(0, -1);
}
const specificConfigPromise = getConfig(`${relativeLocation}config.${domain}.json`);
const generalConfigPromise = getConfig(relativeLocation + "config.json");
try {