37 lines
736 B
Swift
37 lines
736 B
Swift
import Foundation
|
|
import SwiftUI
|
|
|
|
// MARK: - URL Extensions
|
|
|
|
extension URL {
|
|
var isHLS: Bool {
|
|
pathExtension.lowercased() == "m3u8" || absoluteString.contains(".m3u8")
|
|
}
|
|
}
|
|
|
|
// MARK: - String Extensions
|
|
|
|
extension String {
|
|
var trimmed: String {
|
|
trimmingCharacters(in: .whitespacesAndNewlines)
|
|
}
|
|
|
|
func extractNumbers() -> [Int] {
|
|
components(separatedBy: CharacterSet.decimalDigits.inverted)
|
|
.compactMap { Int($0) }
|
|
}
|
|
}
|
|
|
|
// MARK: - View Extensions
|
|
|
|
extension View {
|
|
@ViewBuilder
|
|
func `if`<Content: View>(_ condition: Bool, transform: (Self) -> Content) -> some View {
|
|
if condition {
|
|
transform(self)
|
|
} else {
|
|
self
|
|
}
|
|
}
|
|
}
|