Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

server_form: Added autocomplete function to url. #1043

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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