25 lines
522 B
Swift
25 lines
522 B
Swift
|
/**
|
||
|
* Splash
|
||
|
* Copyright (c) John Sundell 2019
|
||
|
* MIT license - see LICENSE.md
|
||
|
*/
|
||
|
|
||
|
import Foundation
|
||
|
|
||
|
internal extension StringProtocol {
|
||
|
func escapingHTMLEntities() -> String {
|
||
|
return String(flatMap { character -> String in
|
||
|
switch character {
|
||
|
case "&":
|
||
|
return "&"
|
||
|
case "<":
|
||
|
return "<"
|
||
|
case ">":
|
||
|
return ">"
|
||
|
default:
|
||
|
return String(character)
|
||
|
}
|
||
|
})
|
||
|
}
|
||
|
}
|