diff --git a/Sources/mas/Controllers/MasStoreSearch.swift b/Sources/mas/Controllers/MasStoreSearch.swift index f0f6481..9cf2405 100644 --- a/Sources/mas/Controllers/MasStoreSearch.swift +++ b/Sources/mas/Controllers/MasStoreSearch.swift @@ -40,7 +40,7 @@ class MasStoreSearch: StoreSearch { func search(for appName: String) -> Promise<[SearchResult]> { // Search for apps for compatible platforms, in order of preference. // Macs with Apple Silicon can run iPad and iPhone apps. - var entities = [Entity.macSoftware] + var entities = [Entity.desktopSoftware] if SysCtlSystemCommand.isAppleSilicon { entities += [.iPadSoftware, .iPhoneSoftware] } diff --git a/Sources/mas/Controllers/StoreSearch.swift b/Sources/mas/Controllers/StoreSearch.swift index b04ef13..62775cc 100644 --- a/Sources/mas/Controllers/StoreSearch.swift +++ b/Sources/mas/Controllers/StoreSearch.swift @@ -16,6 +16,7 @@ protocol StoreSearch { } enum Entity: String { + case desktopSoftware case macSoftware case iPadSoftware case iPhoneSoftware = "software" @@ -27,7 +28,11 @@ extension StoreSearch { /// /// - Parameter appName: MAS app identifier. /// - Returns: URL for the search service or nil if appName can't be encoded. - func searchURL(for appName: String, inCountry country: String?, ofEntity entity: Entity = .macSoftware) -> URL? { + func searchURL( + for appName: String, + inCountry country: String?, + ofEntity entity: Entity = .desktopSoftware + ) -> URL? { guard var components = URLComponents(string: "https://itunes.apple.com/search") else { return nil } diff --git a/Tests/masTests/Controllers/MasStoreSearchSpec.swift b/Tests/masTests/Controllers/MasStoreSearchSpec.swift index 8d9c6f7..c85aea1 100644 --- a/Tests/masTests/Controllers/MasStoreSearchSpec.swift +++ b/Tests/masTests/Controllers/MasStoreSearchSpec.swift @@ -18,17 +18,16 @@ public class MasStoreSearchSpec: QuickSpec { } describe("url string") { it("contains the app name") { - let appName = "myapp" expect { - MasStoreSearch().searchURL(for: appName, inCountry: "US")?.absoluteString + MasStoreSearch().searchURL(for: "myapp", inCountry: "US")?.absoluteString } - == "https://itunes.apple.com/search?media=software&entity=macSoftware&term=\(appName)&country=US" + == "https://itunes.apple.com/search?media=software&entity=desktopSoftware&term=myapp&country=US" } it("contains the encoded app name") { expect { MasStoreSearch().searchURL(for: "My App", inCountry: "US")?.absoluteString } - == "https://itunes.apple.com/search?media=software&entity=macSoftware&term=My%20App&country=US" + == "https://itunes.apple.com/search?media=software&entity=desktopSoftware&term=My%20App&country=US" } } describe("store") {