2022-12-04 12:21:50 +00:00
|
|
|
import Foundation
|
|
|
|
|
|
|
|
extension URL {
|
|
|
|
func byReplacingYatteeProtocol(with urlProtocol: String = "https") -> URL! {
|
|
|
|
var urlAbsoluteString = absoluteString
|
|
|
|
|
2024-05-16 16:53:47 +00:00
|
|
|
guard urlAbsoluteString.hasPrefix(Strings.yatteeProtocol) else {
|
2022-12-04 12:21:50 +00:00
|
|
|
return self
|
|
|
|
}
|
|
|
|
|
2024-05-16 16:53:47 +00:00
|
|
|
urlAbsoluteString = String(urlAbsoluteString.dropFirst(Strings.yatteeProtocol.count))
|
2022-12-04 12:21:50 +00:00
|
|
|
if absoluteString.contains("://") {
|
|
|
|
return URL(string: urlAbsoluteString)
|
|
|
|
}
|
|
|
|
|
|
|
|
return URL(string: "\(urlProtocol)://\(urlAbsoluteString)")
|
|
|
|
}
|
|
|
|
}
|