Merge pull request #196 from hyperspacedev/HD-63-location-slash-fix

HD-63 #done
This commit is contained in:
Marquis Kurt 2020-04-14 13:32:04 -04:00 committed by GitHub
commit 8432ad5a24
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 11 additions and 4 deletions

View File

@ -133,18 +133,25 @@ export function createUserDefaults() {
} }
/** /**
* Gets the configuration data from `config.json` * Gets the configuration data from `config.json`.
*
* In scenarios where the app is being run from the desktop or from a local React server
* started by react-scripts, the location field is adjusted accordingly.
*
* @returns The Promise data from getting the config. * @returns The Promise data from getting the config.
*/ */
export async function getConfig(): Promise<Config | undefined> { export async function getConfig(): Promise<Config | undefined> {
try { try {
const resp = await axios.get("config.json"); const resp = await axios.get("config.json");
let { location } = resp.data; let { location }: { location: string } = resp.data;
if (!location.endsWith("/")) { if (
!location.endsWith("/") &&
(location !== "desktop" && location !== "dynamic")
) {
console.info( console.info(
"Location does not have a backslash, so Hyperspace has added it automatically." "Location does not have a forward slash, so Hyperspace has added it automatically."
); );
resp.data.location = location + "/"; resp.data.location = location + "/";
} }