From 1d51b94d41bef0186575c98fbd1489e8247f808a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Odd=20Str=C3=A5b=C3=B8?= Date: Tue, 24 Nov 2020 20:44:14 +0100 Subject: [PATCH] Address review --- src/scripts/clientUtils.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/scripts/clientUtils.js b/src/scripts/clientUtils.js index 5ac27a68d6..69d64c671e 100644 --- a/src/scripts/clientUtils.js +++ b/src/scripts/clientUtils.js @@ -29,10 +29,10 @@ export async function serverAddress() { // if (current) return Promise.resolve(current); const urls = []; - if (window.location.href.indexOf('/web/') !== -1) { // Do we polyfill String.prototype.includes? + if (window.location.href.indexOf('/web/') !== -1) { const split = window.location.href.split('/web/'); - for (let i = split.length - 1; i ; i--) { + for (let i = split.length - 1; i > 0; i--) { urls.push(split.slice(0, i).join('/web/')); } } @@ -45,7 +45,7 @@ export async function serverAddress() { urls.push(...await webSettings.getServers()); - console.log('URL candidates:', urls); + console.debug('URL candidates:', urls); const promises = urls.map(url => { return fetch(`${url}/System/Info/Public`).then(resp => { @@ -67,8 +67,7 @@ export async function serverAddress() { }; })); }).then(configs => { - let selection = configs.find(obj => !obj.config.StartupWizardCompleted); - if (!selection) selection = configs[0]; + let selection = configs.find(obj => !obj.config.StartupWizardCompleted) || configs[0]; return Promise.resolve(selection.url); }).catch(error => { console.log(error);