1
0
mirror of https://github.com/metabolist/metatext synced 2024-12-29 03:01:07 +01:00
metatext-app-ios-iphone-ipad/Extensions/URL+Extensions.swift

28 lines
727 B
Swift
Raw Normal View History

2020-09-12 04:50:42 +02:00
// Copyright © 2020 Metabolist. All rights reserved.
import Foundation
extension URL {
var isHTTPURL: Bool {
guard let scheme = scheme else { return false }
return scheme == "http" || scheme == "https"
}
2021-02-27 22:29:30 +01:00
init?(stringEscapingPath: String) {
guard let pathEscaped = stringEscapingPath.addingPercentEncoding(withAllowedCharacters: .urlPathAllowed)
else { return nil }
let httpsColonUnescaped = pathEscaped.replacingOccurrences(
of: "https%3A",
with: "https:",
range: pathEscaped.range(of: "https%3A"))
self.init(string: httpsColonUnescaped)
}
}
2020-09-12 04:50:42 +02:00
extension URL: Identifiable {
public var id: String { absoluteString }
}