Skip to content

Commit 58c0768

Browse files
committed
fix: refactor service
1 parent 3c0e29c commit 58c0768

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

Sources/FSAppConfiguration/FSAppConfiguration.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -121,13 +121,13 @@ public struct FSAppConfiguration {
121121
private func getVersionFromConsul(by path: URI) -> EventLoopFuture<String> {
122122
self.app.client.get(path).map { response -> String in
123123
let dataValue = self.decode(response, path)
124-
let versionString = String(decoding: dataValue, as: UTF8.self)
124+
let versionString = String(decoding: dataValue, as: UTF8.self).replacingOccurrences(of: "\n", with: "")
125125
if versionString.isEmpty {
126126
self.app.logger.error("ERROR: Encoded empty value by '\(path)' in consul")
127127
return ""
128128
} else {
129129
self.app.logger.info("SUCCESS: Encoded '\(versionString)' by '\(path)' from consul")
130-
return versionString.replacingOccurrences(of: "\n", with: "")
130+
return versionString
131131
}
132132
}
133133
}
@@ -171,12 +171,12 @@ public struct FSAppConfiguration {
171171
self.app.logger.error("ERROR: Failed to load Version file at the file path - '\(versionPath)'")
172172
fatalError("ERROR: Failed to load Version file at the file path - '\(versionPath)'")
173173
}
174-
guard let versionString = String(data: versionValue, encoding: .utf8), !versionString.isEmpty else {
174+
guard let versionString = String(data: versionValue, encoding: .utf8)?.replacingOccurrences(of: "\n", with: ""), !versionString.isEmpty else {
175175
self.app.logger.error("ERROR: Failed to encoding Version value from - '\(versionValue)'")
176176
fatalError("ERROR: Failed to encoding Version value from - '\(versionValue)'")
177177
}
178178
self.app.logger.info("SUCCESS: Get the Version - \(versionString) from the local machine along the file path \(versionPath)")
179-
return versionString.replacingOccurrences(of: "\n", with: "")
179+
return versionString
180180
}
181181

182182
/// Decode Consul `ClientResponse`

Sources/FSAppConfiguration/FSAppConfigurationAsync.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,13 +98,13 @@ public struct FSAppConfigurationAsync {
9898
private func getVersionFromConsul(by path: URI) async throws -> String {
9999
try await self.app.client.get(path).map { response -> String in
100100
let dataValue = self.decode(response, path)
101-
let versionString = String(decoding: dataValue, as: UTF8.self)
101+
let versionString = String(decoding: dataValue, as: UTF8.self).replacingOccurrences(of: "\n", with: "")
102102
if versionString.isEmpty {
103103
self.app.logger.error("ERROR: Encoded empty value by '\(path)' in consul")
104104
return ""
105105
} else {
106106
self.app.logger.info("SUCCESS: Encoded '\(versionString)' by '\(path)' from consul")
107-
return versionString.replacingOccurrences(of: "\n", with: "")
107+
return versionString
108108
}
109109
}.get()
110110
}
@@ -171,12 +171,12 @@ public struct FSAppConfigurationAsync {
171171
self.app.logger.error("ERROR: Failed to load Version file at the file path - '\(versionPath)'")
172172
fatalError("ERROR: Failed to load Version file at the file path - '\(versionPath)'")
173173
}
174-
guard let versionString = String(data: versionValue, encoding: .utf8), !versionString.isEmpty else {
174+
guard let versionString = String(data: versionValue, encoding: .utf8)?.replacingOccurrences(of: "\n", with: ""), !versionString.isEmpty else {
175175
self.app.logger.error("ERROR: Failed to encoding Version value from - '\(versionValue)'")
176176
fatalError("ERROR: Failed to encoding Version value from - '\(versionValue)'")
177177
}
178178
self.app.logger.info("SUCCESS: Get the Version - \(versionString) from the local machine along the file path \(versionPath)")
179-
return versionString.replacingOccurrences(of: "\n", with: "")
179+
return versionString
180180
}
181181

182182
/// Decode Consul `ClientResponse`

0 commit comments

Comments
 (0)