mirror of
https://github.com/nicoverbruggen/phpmon.git
synced 2025-11-08 05:30:05 +01:00
👌 Improve proxy subject validation
This commit is contained in:
@@ -63,8 +63,6 @@ class AddProxyVC: NSViewController, NSTextFieldDelegate {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@IBAction func pressedCreateProxy(_ sender: Any) {
|
@IBAction func pressedCreateProxy(_ sender: Any) {
|
||||||
// TODO: Validate the input before allowing proxy creation
|
|
||||||
|
|
||||||
let domain = self.inputDomainName.stringValue
|
let domain = self.inputDomainName.stringValue
|
||||||
let proxyName = self.inputProxySubject.stringValue
|
let proxyName = self.inputProxySubject.stringValue
|
||||||
let secure = self.buttonSecure.state == .on ? " --secure" : ""
|
let secure = self.buttonSecure.state == .on ? " --secure" : ""
|
||||||
@@ -104,18 +102,24 @@ class AddProxyVC: NSViewController, NSTextFieldDelegate {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private func validate(domain: String, proxy: String) -> Bool {
|
private func validate(domain: String, proxy: String) -> Bool {
|
||||||
if domain.isEmpty {
|
|
||||||
textFieldError.isHidden = false
|
|
||||||
textFieldError.stringValue = "domain_list.add.errors.empty".localized
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
if proxy.isEmpty {
|
if proxy.isEmpty {
|
||||||
textFieldError.isHidden = false
|
textFieldError.isHidden = false
|
||||||
textFieldError.stringValue = "domain_list.add.errors.empty_proxy".localized
|
textFieldError.stringValue = "domain_list.add.errors.empty_proxy".localized
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if proxy.range(of: #"(http:\/\/|https:\/\/)(.*)(:)(\d*)"#, options: .regularExpression) == nil {
|
||||||
|
textFieldError.isHidden = false
|
||||||
|
textFieldError.stringValue = "domain_list.add.errors.subject_invalid".localized
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
if domain.isEmpty {
|
||||||
|
textFieldError.isHidden = false
|
||||||
|
textFieldError.stringValue = "domain_list.add.errors.empty".localized
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
if Valet.shared.sites.contains(where: { $0.name == domain }) {
|
if Valet.shared.sites.contains(where: { $0.name == domain }) {
|
||||||
textFieldError.isHidden = false
|
textFieldError.isHidden = false
|
||||||
textFieldError.stringValue = "domain_list.add.errors.already_exists".localized
|
textFieldError.stringValue = "domain_list.add.errors.already_exists".localized
|
||||||
|
|||||||
@@ -106,7 +106,7 @@
|
|||||||
// ADD PROXY TO DOMAINS LIST
|
// ADD PROXY TO DOMAINS LIST
|
||||||
|
|
||||||
"domain_list.add.set_up_proxy" = "Set up a Proxy";
|
"domain_list.add.set_up_proxy" = "Set up a Proxy";
|
||||||
"domain_list.add.proxy_subject" = "Proxy subject (usually: protocol, IP address and port)";
|
"domain_list.add.proxy_subject" = "Proxy subject (must include protocol and port)";
|
||||||
"domain_list.add.domain_name" = "Domain name";
|
"domain_list.add.domain_name" = "Domain name";
|
||||||
"domain_list.add.create_proxy" = "Create Proxy";
|
"domain_list.add.create_proxy" = "Create Proxy";
|
||||||
"domain_list.add.proxy_available" = "%@ will be proxied and will be available via: %@://%@.%@";
|
"domain_list.add.proxy_available" = "%@ will be proxied and will be available via: %@://%@.%@";
|
||||||
@@ -124,6 +124,7 @@
|
|||||||
"domain_list.add.empty_fields" = "One or more fields are empty. Please fill all required fields.";
|
"domain_list.add.empty_fields" = "One or more fields are empty. Please fill all required fields.";
|
||||||
"domain_list.add.errors.empty" = "You must enter a domain name.";
|
"domain_list.add.errors.empty" = "You must enter a domain name.";
|
||||||
"domain_list.add.errors.empty_proxy" = "You must enter what will be proxied.";
|
"domain_list.add.errors.empty_proxy" = "You must enter what will be proxied.";
|
||||||
|
"domain_list.add.errors.subject_invalid" = "The subject you've entered is not valid.\nYou must include the protocol and port.";
|
||||||
"domain_list.add.errors.already_exists" = "A link with that name already exists.";
|
"domain_list.add.errors.already_exists" = "A link with that name already exists.";
|
||||||
|
|
||||||
// ADD SITE ERROR: FOLDER MISSING SINCE SELECTION
|
// ADD SITE ERROR: FOLDER MISSING SINCE SELECTION
|
||||||
|
|||||||
Reference in New Issue
Block a user