macOS 13, iOS 16 version only

This commit is contained in:
Balazs Perlaki-Horvath 2024-06-08 15:00:54 +02:00 committed by Kelson
parent 1cb73253cd
commit cc4c2aa4b7

View File

@ -52,18 +52,7 @@ extension URL {
/// It makes sure that trailing slash is preserved,
/// and leading slash is removed.
var contentPath: String {
if #available(macOS 13.0, iOS 16.0, *) {
return path(percentEncoded: false).removingPrefix("/")
} else {
var path: String = [scheme, "://", host, "/"]
.compactMap { $0 }
.reduce(absoluteString) { partialResult, prefix in
partialResult.removingPrefix(prefix)
}
path = path.removingPercentEncoding ?? path
path = (try? path.replacingRegex(matching: "#.*", with: "")) ?? path
return path
}
path(percentEncoded: false).removingPrefix("/")
}
// swiftlint:disable:next force_try