Skip to content
Permalink
Browse files

Strip schema and path component from new server addresses

We have had reports that a lot of users out of habit add
http:// or https:// schemas to server addresses when adding
a new server. This patch changes the ConnectDialogEdit to
drop schema and path components from server addresses if
present. This happens automatically when accepting the
dialog.
  • Loading branch information...
hacst committed Jun 8, 2015
1 parent 3d46634 commit 7fbe61e51f72792a46840c28b218f1c4c753dff4
Showing with 20 additions and 3 deletions.
  1. +20 −3 src/mumble/ConnectDialog.cpp
@@ -797,11 +797,28 @@ void ConnectDialogEdit::validate() {
void ConnectDialogEdit::accept() {
validate();
if (bOk) {
if (qleName->text().simplified().isEmpty()) {
qleName->setText(qleServer->text());
QString server = qleServer->text().simplified();

// If the user accidentally added a schema or path part, drop it now.
// We can't do so during editing as that is quite jarring.
const int schemaPos = server.indexOf(QLatin1String("://"));
if (schemaPos != -1) {
server.remove(0, schemaPos + 3);
}

const int pathPos = server.indexOf(QLatin1Char('/'));
if (pathPos != -1) {
server.resize(pathPos);
}

qleServer->setText(server);

if (qleName->text().simplified().isEmpty() || !bCustomLabel) {
qleName->setText(server);
}

QDialog::accept();
}
}
}

void ConnectDialogEdit::on_qcbShowPassword_toggled(bool checked) {

0 comments on commit 7fbe61e

Please sign in to comment.
You can’t perform that action at this time.