Skip to content

Commit

Permalink
server_form: Added autocomplete function to url.
Browse files Browse the repository at this point in the history
Autocompletes when the user passes only org url,
in the server url input.

Fixes zulip#1012
  • Loading branch information
aryanshridhar authored and manila committed May 6, 2022
1 parent 588d32f commit c390ca8
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion app/renderer/js/pages/preference/new-server-form.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ export function initNewServerForm({$root, onChange}: NewServerFormProps): void {
"input.setting-input-value",
)!;

<<<<<<< HEAD
async function submitFormHandler(): Promise<void> {
$saveServerButton.textContent = "Connecting...";
let serverConf;
Expand All @@ -73,11 +74,21 @@ export function initNewServerForm({$root, onChange}: NewServerFormProps): void {
});
return;
}

await DomainUtil.addDomain(serverConf);
onChange();
}

autoComplete(url: string): string {
const pattern = /^[a-zA-Z\d-]*$/;
let serverUrl = url.trim();

if (pattern.test(serverUrl)) {
serverUrl = 'https://' + serverUrl + '.zulipchat.com';
}

return serverUrl;
}

$saveServerButton.addEventListener("click", async () => {
await submitFormHandler();
});
Expand Down

0 comments on commit c390ca8

Please sign in to comment.