16 lines
413 B
Swift
16 lines
413 B
Swift
|
|
extension String {
|
|
|
|
func htmlEscaped() -> String {
|
|
replacingOccurrences(of: "&", with: "&")
|
|
.replacingOccurrences(of: "\"", with: """)
|
|
.replacingOccurrences(of: "'", with: "'")
|
|
.replacingOccurrences(of: "<", with: "<")
|
|
.replacingOccurrences(of: ">", with: ">")
|
|
}
|
|
|
|
var nonEmpty: String? {
|
|
isEmpty ? nil : self
|
|
}
|
|
}
|