Skip to content

Commit c390ca8

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 zulip#1012
1 parent 588d32f commit c390ca8

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

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

+12-1
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ export function initNewServerForm({$root, onChange}: NewServerFormProps): void {
5656
"input.setting-input-value",
5757
)!;
5858

59+
<<<<<<< HEAD
5960
async function submitFormHandler(): Promise<void> {
6061
$saveServerButton.textContent = "Connecting...";
6162
let serverConf;
@@ -73,11 +74,21 @@ export function initNewServerForm({$root, onChange}: NewServerFormProps): void {
7374
});
7475
return;
7576
}
76-
7777
await DomainUtil.addDomain(serverConf);
7878
onChange();
7979
}
8080

81+
autoComplete(url: string): string {
82+
const pattern = /^[a-zA-Z\d-]*$/;
83+
let serverUrl = url.trim();
84+
85+
if (pattern.test(serverUrl)) {
86+
serverUrl = 'https://' + serverUrl + '.zulipchat.com';
87+
}
88+
89+
return serverUrl;
90+
}
91+
8192
$saveServerButton.addEventListener("click", async () => {
8293
await submitFormHandler();
8394
});

0 commit comments

Comments
 (0)