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 committed Nov 18, 2020
1 parent ba432d3 commit cb8df9b
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 @@ -65,11 +65,22 @@ export default class NewServerForm extends BaseComponent {
this.$newServerUrl = this.$newServerForm.querySelectorAll('input.setting-input-value')[0] as HTMLInputElement;
}

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;
}

async submitFormHandler(): Promise<void> {
this.$saveServerButton.textContent = 'Connecting...';
let serverConf;
try {
serverConf = await DomainUtil.checkDomain(this.$newServerUrl.value.trim());
serverConf = await DomainUtil.checkDomain(this.autoComplete(this.$newServerUrl.value));
} catch (error: unknown) {
this.$saveServerButton.textContent = 'Connect';
await dialog.showMessageBox({
Expand Down

0 comments on commit cb8df9b

Please sign in to comment.