Skip to content

Commit 71c69f5

Browse files
aryanshridharmanila
authored andcommitted
server_form: Added autocomplete function to url.
Autocompletes when the user passes only org url, in the server url input. Fixes #1012
1 parent 588d32f commit 71c69f5

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

app/renderer/js/pages/preference/new-server-form.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,9 @@ export function initNewServerForm({$root, onChange}: NewServerFormProps): void {
6060
$saveServerButton.textContent = "Connecting...";
6161
let serverConf;
6262
try {
63-
serverConf = await DomainUtil.checkDomain($newServerUrl.value.trim());
63+
serverConf = await DomainUtil.checkDomain(
64+
await autoComplete($newServerUrl.value.trim()),
65+
);
6466
} catch (error: unknown) {
6567
$saveServerButton.textContent = "Connect";
6668
await dialog.showMessageBox({
@@ -78,6 +80,17 @@ export function initNewServerForm({$root, onChange}: NewServerFormProps): void {
7880
onChange();
7981
}
8082

83+
async function autoComplete(url: string): Promise<string> {
84+
const pattern = /^[a-zA-Z\d-]*$/;
85+
let serverUrl = url.trim();
86+
87+
if (pattern.test(serverUrl)) {
88+
serverUrl = "https://" + serverUrl + ".zulipchat.com";
89+
}
90+
91+
return serverUrl;
92+
}
93+
8194
$saveServerButton.addEventListener("click", async () => {
8295
await submitFormHandler();
8396
});

0 commit comments

Comments
 (0)