mirror of
https://github.com/yattee/yattee.git
synced 2024-11-10 00:08:21 +00:00
19 lines
551 B
Swift
19 lines
551 B
Swift
|
import Foundation
|
||
|
|
||
|
extension URL {
|
||
|
func byReplacingYatteeProtocol(with urlProtocol: String = "https") -> URL! {
|
||
|
var urlAbsoluteString = absoluteString
|
||
|
|
||
|
guard urlAbsoluteString.hasPrefix(Constants.yatteeProtocol) else {
|
||
|
return self
|
||
|
}
|
||
|
|
||
|
urlAbsoluteString = String(urlAbsoluteString.dropFirst(Constants.yatteeProtocol.count))
|
||
|
if absoluteString.contains("://") {
|
||
|
return URL(string: urlAbsoluteString)
|
||
|
}
|
||
|
|
||
|
return URL(string: "\(urlProtocol)://\(urlAbsoluteString)")
|
||
|
}
|
||
|
}
|