Trim whitespaces in text fields
This commit is contained in:
parent
08008dda23
commit
2ab709401f
|
@ -15,6 +15,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
|
||||
- Release app in the open via GitHub Actions.
|
||||
|
||||
### Fixed
|
||||
|
||||
- Trim whitespaces in text fields.
|
||||
|
||||
## 1.17.2 (2021-11-30)
|
||||
|
||||
### Changed
|
||||
|
|
|
@ -250,18 +250,15 @@ class NetworkSettingsViewController: UITableViewController {
|
|||
// DNS: servers, domains
|
||||
// Proxy: address, port, PAC, bypass domains
|
||||
|
||||
let text = field.text ?? ""
|
||||
let text = field.text?.stripped ?? ""
|
||||
|
||||
if field.tag == FieldTag.dnsCustom.rawValue {
|
||||
switch networkSettings.dnsProtocol {
|
||||
case .https:
|
||||
guard let string = field.text, let url = URL(string: string) else {
|
||||
break
|
||||
}
|
||||
networkSettings.dnsHTTPSURL = url
|
||||
networkSettings.dnsHTTPSURL = URL(string: text)
|
||||
|
||||
case .tls:
|
||||
networkSettings.dnsTLSServerName = field.text
|
||||
networkSettings.dnsTLSServerName = text
|
||||
|
||||
default:
|
||||
break
|
||||
|
@ -281,11 +278,11 @@ class NetworkSettingsViewController: UITableViewController {
|
|||
networkSettings.dnsSearchDomains = [text]
|
||||
}
|
||||
} else if field.tag == FieldTag.proxyAddress.rawValue {
|
||||
networkSettings.proxyAddress = field.text
|
||||
networkSettings.proxyAddress = text
|
||||
} else if field.tag == FieldTag.proxyPort.rawValue {
|
||||
networkSettings.proxyPort = UInt16(field.text ?? "0")
|
||||
networkSettings.proxyPort = UInt16(text) ?? 0
|
||||
} else if field.tag == FieldTag.proxyAutoConfigurationURL.rawValue {
|
||||
if let string = field.text {
|
||||
if let string = text {
|
||||
networkSettings.proxyAutoConfigurationURL = URL(string: string)
|
||||
} else {
|
||||
networkSettings.proxyAutoConfigurationURL = nil
|
||||
|
|
|
@ -95,7 +95,7 @@ class WizardHostViewController: UITableViewController, StrongTableHost {
|
|||
}
|
||||
|
||||
@IBAction private func next() {
|
||||
guard let enteredTitle = cellTitle?.field.text?.trimmingCharacters(in: .whitespaces), !enteredTitle.isEmpty else {
|
||||
guard let enteredTitle = cellTitle?.field.text?.stripped, !enteredTitle.isEmpty else {
|
||||
return
|
||||
}
|
||||
guard let result = parsingResult else {
|
||||
|
|
|
@ -449,10 +449,11 @@ class ServiceViewController: UIViewController, StrongTableHost {
|
|||
}
|
||||
alert.addCancelAction(L10n.Global.cancel)
|
||||
alert.addPreferredAction(L10n.Service.Cells.TrustedAddWifi.caption) {
|
||||
guard let wifi = alert.textFields?.first?.text else {
|
||||
let ssid = alert.textFields?.first?.text?.stripped
|
||||
guard let ssid = ssid, !ssid.isEmpty else {
|
||||
return
|
||||
}
|
||||
self.trustedNetworks.addWifi(wifi)
|
||||
self.trustedNetworks.addWifi(ssid)
|
||||
}
|
||||
present(alert, animated: true, completion: nil)
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
### Fixed
|
||||
|
||||
- Last update was not refreshed on "Refresh infrastructure".
|
||||
- Trim whitespaces in text fields.
|
||||
|
||||
## 1.17.2 (2021-11-30)
|
||||
|
||||
|
|
|
@ -158,7 +158,7 @@ class DNSViewController: NSViewController, ProfileCustomization {
|
|||
networkSettings.dnsHTTPSURL = URL(string: textDNSCustom.stringValue)
|
||||
|
||||
case .tls:
|
||||
networkSettings.dnsTLSServerName = textDNSCustom.stringValue
|
||||
networkSettings.dnsTLSServerName = textDNSCustom.stringValue.stripped
|
||||
|
||||
default:
|
||||
break
|
||||
|
|
|
@ -112,7 +112,7 @@ class ProxyViewController: NSViewController, ProfileCustomization {
|
|||
return
|
||||
}
|
||||
view.endEditing()
|
||||
networkSettings.proxyAddress = textProxyAddress.stringValue
|
||||
networkSettings.proxyAddress = textProxyAddress.stringValue.stripped
|
||||
networkSettings.proxyPort = UInt16(textProxyPort.stringValue)
|
||||
networkSettings.proxyAutoConfigurationURL = URL(string: textPAC.stringValue)
|
||||
networkSettings.proxyBypassDomains = tableProxyBypass.rows
|
||||
|
|
|
@ -49,7 +49,7 @@ class TrustedNetworksAddViewController: NSViewController {
|
|||
}
|
||||
|
||||
@IBAction private func confirm(_ sender: Any?) {
|
||||
let ssid = textSSID.stringValue.trimmingCharacters(in: .whitespaces)
|
||||
let ssid = textSSID.stringValue.stripped
|
||||
guard !ssid.isEmpty else {
|
||||
return
|
||||
}
|
||||
|
|
|
@ -143,7 +143,7 @@ extension TextTableView: NSTableViewDataSource, NSTableViewDelegate {
|
|||
rows.remove(at: row)
|
||||
return
|
||||
}
|
||||
rows[row] = string
|
||||
rows[row] = string.stripped
|
||||
}
|
||||
|
||||
func tableViewSelectionDidChange(_ notification: Notification) {
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="14490.70" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
|
||||
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="19529" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
|
||||
<dependencies>
|
||||
<deployment identifier="macosx"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="14490.70"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="19529"/>
|
||||
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
|
||||
</dependencies>
|
||||
<objects>
|
||||
|
@ -14,7 +14,7 @@
|
|||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
|
||||
<subviews>
|
||||
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="DCZ-UA-dFX">
|
||||
<rect key="frame" x="-2" y="162" width="484" height="17"/>
|
||||
<rect key="frame" x="-2" y="163" width="484" height="16"/>
|
||||
<textFieldCell key="cell" lineBreakMode="clipping" title="Title" id="Ck0-u8-8Ph">
|
||||
<font key="font" metaFont="system"/>
|
||||
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
|
||||
|
@ -22,21 +22,20 @@
|
|||
</textFieldCell>
|
||||
</textField>
|
||||
<scrollView autohidesScrollers="YES" horizontalLineScroll="19" horizontalPageScroll="10" verticalLineScroll="19" verticalPageScroll="10" usesPredominantAxisScrolling="NO" translatesAutoresizingMaskIntoConstraints="NO" id="7Q9-YS-n5c">
|
||||
<rect key="frame" x="0.0" y="25" width="480" height="132"/>
|
||||
<rect key="frame" x="0.0" y="25" width="480" height="133"/>
|
||||
<clipView key="contentView" id="Qf5-x5-Ir0">
|
||||
<rect key="frame" x="1" y="1" width="478" height="130"/>
|
||||
<rect key="frame" x="1" y="1" width="478" height="131"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<subviews>
|
||||
<tableView verticalHuggingPriority="750" allowsExpansionToolTips="YES" columnAutoresizingStyle="lastColumnOnly" columnSelection="YES" multipleSelection="NO" autosaveColumns="NO" id="1RC-tv-Pn5">
|
||||
<rect key="frame" x="0.0" y="0.0" width="478" height="130"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<rect key="frame" x="0.0" y="0.0" width="478" height="131"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<size key="intercellSpacing" width="3" height="2"/>
|
||||
<color key="backgroundColor" name="controlBackgroundColor" catalog="System" colorSpace="catalog"/>
|
||||
<color key="gridColor" name="gridColor" catalog="System" colorSpace="catalog"/>
|
||||
<tableColumns>
|
||||
<tableColumn width="475" minWidth="40" maxWidth="1000" id="9bQ-Zp-3Zd">
|
||||
<tableColumn width="466" minWidth="40" maxWidth="1000" id="9bQ-Zp-3Zd">
|
||||
<tableHeaderCell key="headerCell" lineBreakMode="truncatingTail" borderStyle="border">
|
||||
<font key="font" metaFont="smallSystem"/>
|
||||
<color key="textColor" name="headerTextColor" catalog="System" colorSpace="catalog"/>
|
||||
<color key="backgroundColor" name="headerColor" catalog="System" colorSpace="catalog"/>
|
||||
</tableHeaderCell>
|
||||
|
|
|
@ -38,8 +38,8 @@ public extension Credentials {
|
|||
}
|
||||
|
||||
func trimmed() -> Credentials {
|
||||
let trimmedUsername = username.trimmingCharacters(in: .whitespacesAndNewlines)
|
||||
let trimmedPassword = password.trimmingCharacters(in: .whitespacesAndNewlines)
|
||||
let trimmedUsername = username.stripped
|
||||
let trimmedPassword = password.stripped
|
||||
return Credentials(trimmedUsername, trimmedPassword)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -230,3 +230,9 @@ public extension Infrastructure.Metadata {
|
|||
return URL(string: string)
|
||||
}
|
||||
}
|
||||
|
||||
public extension String {
|
||||
var stripped: String {
|
||||
return trimmingCharacters(in: .whitespacesAndNewlines)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue