import Foundation

enum VoltPlanRedirect {
    private static let baseURL = "https://voltplan.app"

    static func componentURL(id: String) -> URL? {
        var components = URLComponents(string: "\(baseURL)/\(id)")
        components?.queryItems = [URLQueryItem(name: "src", value: "cable")]
        return components?.url
    }

    static func searchURL(query: String) -> URL? {
        guard !query.isEmpty else { return nil }
        var components = URLComponents(string: "\(baseURL)/search")
        components?.queryItems = [
            URLQueryItem(name: "q", value: query),
            URLQueryItem(name: "src", value: "cable"),
        ]
        return components?.url
    }
}
