Trim whitespace and protocol / path information

This commit is contained in:
Mira Nord
2025-03-16 21:40:52 +01:00
parent d993157cfa
commit 6dd9a0213c
2 changed files with 5 additions and 2 deletions
+1 -1
View File
@@ -144,7 +144,7 @@ export class SetCustomWebInstanceView extends TemplateView {
evt.preventDefault(); evt.preventDefault();
const form = evt.target; const form = evt.target;
const {instanceHostname} = form.elements; const {instanceHostname} = form.elements;
this.value.setCustomWebInstance(instanceHostname.value || undefined); this.value.setCustomWebInstance(instanceHostname.value);
this.value.closeCustomWebInstanceForm(); this.value.closeCustomWebInstanceForm();
} }
+4 -1
View File
@@ -262,8 +262,11 @@ export class ClientViewModel extends ViewModel {
} }
setCustomWebInstance(hostname) { setCustomWebInstance(hostname) {
if (hostname) {
hostname = hostname.trim().replace(/^https:\/\//, '').replace(/\/.*$/, '');
}
this.preferences.setClient(this._client.id, hostname ? this._webPlatform : (this._nativePlatform || this._webPlatform)); this.preferences.setClient(this._client.id, hostname ? this._webPlatform : (this._nativePlatform || this._webPlatform));
this.preferences.setCustomWebInstance(this._client.id, hostname); this.preferences.setCustomWebInstance(this._client.id, hostname || undefined);
this._update(); this._update();
} }
} }