diff --git a/Sources/mas/Controllers/StoreSearch.swift b/Sources/mas/Controllers/StoreSearch.swift index 62775cc..a0de0ef 100644 --- a/Sources/mas/Controllers/StoreSearch.swift +++ b/Sources/mas/Controllers/StoreSearch.swift @@ -40,13 +40,14 @@ extension StoreSearch { components.queryItems = [ URLQueryItem(name: "media", value: "software"), URLQueryItem(name: "entity", value: entity.rawValue), - URLQueryItem(name: "term", value: appName), ] if let country { components.queryItems!.append(URLQueryItem(name: "country", value: country)) } + components.queryItems!.append(URLQueryItem(name: "term", value: appName)) + return components.url } @@ -60,7 +61,7 @@ extension StoreSearch { } components.queryItems = [ - URLQueryItem(name: "id", value: "\(appID)"), + URLQueryItem(name: "media", value: "software"), URLQueryItem(name: "entity", value: "desktopSoftware"), ] @@ -68,6 +69,8 @@ extension StoreSearch { components.queryItems!.append(URLQueryItem(name: "country", value: country)) } + components.queryItems!.append(URLQueryItem(name: "id", value: "\(appID)")) + return components.url } } diff --git a/Tests/masTests/Controllers/MasStoreSearchSpec.swift b/Tests/masTests/Controllers/MasStoreSearchSpec.swift index c85aea1..9a3b7ff 100644 --- a/Tests/masTests/Controllers/MasStoreSearchSpec.swift +++ b/Tests/masTests/Controllers/MasStoreSearchSpec.swift @@ -21,13 +21,13 @@ public class MasStoreSearchSpec: QuickSpec { expect { MasStoreSearch().searchURL(for: "myapp", inCountry: "US")?.absoluteString } - == "https://itunes.apple.com/search?media=software&entity=desktopSoftware&term=myapp&country=US" + == "https://itunes.apple.com/search?media=software&entity=desktopSoftware&country=US&term=myapp" } it("contains the encoded app name") { expect { MasStoreSearch().searchURL(for: "My App", inCountry: "US")?.absoluteString } - == "https://itunes.apple.com/search?media=software&entity=desktopSoftware&term=My%20App&country=US" + == "https://itunes.apple.com/search?media=software&entity=desktopSoftware&country=US&term=My%20App" } } describe("store") {