IME // Allow a string to ensure its trailing slash.

This commit is contained in:
ShikiSuen 2022-04-11 09:55:30 +08:00
parent 69dfcf3064
commit 26ea968e8b
1 changed files with 9 additions and 0 deletions

View File

@ -333,3 +333,12 @@ extension String: Error {}
extension String: LocalizedError {
public var errorDescription: String? { return self }
}
// MARK: - Ensuring trailing slash of a string:
extension String {
mutating func ensureTrailingSlash() {
if !self.hasSuffix("/") {
self += "/"
}
}
}