mirror of
https://github.com/Dimillian/IceCubesApp.git
synced 2024-12-29 10:30:47 +00:00
23 lines
684 B
Swift
23 lines
684 B
Swift
import Foundation
|
||
|
||
public extension String {
|
||
func escape() -> String {
|
||
replacingOccurrences(of: "&", with: "&")
|
||
.replacingOccurrences(of: "<", with: "<")
|
||
.replacingOccurrences(of: ">", with: ">")
|
||
.replacingOccurrences(of: """, with: "\"")
|
||
.replacingOccurrences(of: "'", with: "'")
|
||
.replacingOccurrences(of: "'", with: "’")
|
||
}
|
||
|
||
func URLSafeBase64ToBase64() -> String {
|
||
var base64 = replacingOccurrences(of: "-", with: "+").replacingOccurrences(of: "_", with: "/")
|
||
let countMod4 = count % 4
|
||
|
||
if countMod4 != 0 {
|
||
base64.append(String(repeating: "=", count: 4 - countMod4))
|
||
}
|
||
|
||
return base64
|
||
}
|
||
}
|