mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-15 10:25:06 -04:00
launcher: addServer: don't allow http and filter spaces while pressing key
This commit is contained in:
parent
096279efd9
commit
8a73fefaaa
@ -33,10 +33,7 @@ import javafx.fxml.FXMLLoader;
|
||||
import javafx.fxml.Initializable;
|
||||
import javafx.scene.Parent;
|
||||
import javafx.scene.Scene;
|
||||
import javafx.scene.control.ButtonType;
|
||||
import javafx.scene.control.Label;
|
||||
import javafx.scene.control.Menu;
|
||||
import javafx.scene.control.MenuItem;
|
||||
import javafx.scene.control.*;
|
||||
import javafx.scene.input.KeyCode;
|
||||
import javafx.scene.input.KeyEvent;
|
||||
import javafx.scene.layout.BorderPane;
|
||||
@ -140,11 +137,15 @@ public class MainWindow implements Initializable {
|
||||
RequiredFieldValidator serverAddressValidator = new RequiredFieldValidator();
|
||||
serverAddressValidator.setMessage(LocaleManager.translate(Strings.SERVER_ADDRESS_INPUT_REQUIRED));
|
||||
serverAddressField.getValidators().add(serverAddressValidator);
|
||||
serverAddressField.focusedProperty().addListener((o, oldValue, newValue) -> {
|
||||
serverAddressField.focusedProperty().addListener((observableValue, oldValue, newValue) -> {
|
||||
if (!newValue) {
|
||||
serverAddressField.validate();
|
||||
}
|
||||
});
|
||||
serverAddressField.setTextFormatter(new TextFormatter<String>((change) -> {
|
||||
change.setText(DNSUtil.correctHostName(change.getText()));
|
||||
return change;
|
||||
}));
|
||||
|
||||
GUITools.VERSION_COMBO_BOX.getSelectionModel().select(Versions.LOWEST_VERSION_SUPPORTED);
|
||||
|
||||
|
@ -18,6 +18,7 @@ import org.xbill.DNS.Record;
|
||||
import org.xbill.DNS.*;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.Locale;
|
||||
|
||||
public final class DNSUtil {
|
||||
|
||||
@ -53,7 +54,6 @@ public final class DNSUtil {
|
||||
|
||||
public static String correctHostName(String hostname) {
|
||||
// replaces invalid chars to avoid copy and paste issues (like spaces, ...)
|
||||
hostname = hostname.replaceAll("\\s", "");
|
||||
return hostname.toLowerCase();
|
||||
return hostname.replaceAll("\\s+|((https|http):/{2})+|/", "").toLowerCase(Locale.ROOT);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user