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