diff --git a/Sources/ToolboxAPIClient/BaseNetworkWorker.swift b/Sources/ToolboxAPIClient/BaseNetworkWorker.swift index efb09c9..6dc9ed1 100644 --- a/Sources/ToolboxAPIClient/BaseNetworkWorker.swift +++ b/Sources/ToolboxAPIClient/BaseNetworkWorker.swift @@ -18,18 +18,16 @@ public class BaseNetworkWorker where T: Codable { private var finalUrl: URL { get { - // var components = URLComponents() - // components.scheme = "http" - // components.host = "localhost" - // components.port = 8080 - // components.path = "/professions" - //// //components.queryItems = targetType.queryString - // guard let url = components.url else { - // preconditionFailure("Invalid URL components: \(components)") - // } - // return url - let url = targetType.baseURL.appendingPathComponent(targetType.path) - return url + var components = URLComponents(url: targetType.baseURL, resolvingAgainstBaseURL: true) + print(targetType) + if targetType.queryString.count > 0 { + components?.queryItems = targetType.queryString + } + guard let url = components?.url else { + preconditionFailure("Invalid URL components") + } + let finalUrl: URL = url.appendingPathComponent(targetType.path) + return finalUrl } } diff --git a/Tests/ToolboxAPIClientTests/Network/Story/Targets/StoryTarget.swift b/Tests/ToolboxAPIClientTests/Network/Story/Targets/StoryTarget.swift index a9f838c..eb45571 100644 --- a/Tests/ToolboxAPIClientTests/Network/Story/Targets/StoryTarget.swift +++ b/Tests/ToolboxAPIClientTests/Network/Story/Targets/StoryTarget.swift @@ -34,7 +34,7 @@ extension StoryTarget: TargetType { } public var baseURL: URL { - URL(string: "https://astronomia-api.herokuapp.com/")! + URL(string: "https://astronomia-staging.herokuapp.com/")! } public var path: String { @@ -59,6 +59,6 @@ extension StoryTarget: TargetType { } public var headers: [String : String]? { - ["Authorization": "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyaWQiOiIxMTY3MDNFOS1CRjdFLTQyMEEtQjhFRi1BMjY1MTI5NzlEMjEiLCJzdWIiOiJhc3Ryb25vbWlhX2FwaSIsImV4cCI6NjQwOTIyMTEyMDAsImFkbWluIjp0cnVlfQ.D-ZoYLLVfdGaXrIfVl5BlKslN2oFezBpa0PguKCXmhs"] + ["Authorization": "Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyaWQiOiI4NUNFMjJCMi0xMzExLTRCRjgtOUIwMy1GQTFCREYzQkUyOTIiLCJzdWIiOiJhc3Ryb25vbWlhX2FwaSIsImV4cCI6NjQwOTIyMTEyMDAsImFkbWluIjp0cnVlfQ.0AR701FCTjs9A90Nev5GGgVujnXwV4wgSkCrqjVkhYg"] } }