mirror of
https://github.com/mas-cli/mas
synced 2024-11-24 20:43:10 +00:00
Add & use Entity.desktopSoftware
instead of macSoftware
.
`desktopSoftware` returns info (including version & description) that aligns with what is displayed earlier in the App Store, while `macSoftware` is at least sometimes out of alignment. Partial #561 Signed-off-by: Ross Goldberg <484615+rgoldberg@users.noreply.github.com>
This commit is contained in:
parent
6489daa0e3
commit
6c5a277ad9
3 changed files with 10 additions and 6 deletions
|
@ -40,7 +40,7 @@ class MasStoreSearch: StoreSearch {
|
||||||
func search(for appName: String) -> Promise<[SearchResult]> {
|
func search(for appName: String) -> Promise<[SearchResult]> {
|
||||||
// Search for apps for compatible platforms, in order of preference.
|
// Search for apps for compatible platforms, in order of preference.
|
||||||
// Macs with Apple Silicon can run iPad and iPhone apps.
|
// Macs with Apple Silicon can run iPad and iPhone apps.
|
||||||
var entities = [Entity.macSoftware]
|
var entities = [Entity.desktopSoftware]
|
||||||
if SysCtlSystemCommand.isAppleSilicon {
|
if SysCtlSystemCommand.isAppleSilicon {
|
||||||
entities += [.iPadSoftware, .iPhoneSoftware]
|
entities += [.iPadSoftware, .iPhoneSoftware]
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,6 +16,7 @@ protocol StoreSearch {
|
||||||
}
|
}
|
||||||
|
|
||||||
enum Entity: String {
|
enum Entity: String {
|
||||||
|
case desktopSoftware
|
||||||
case macSoftware
|
case macSoftware
|
||||||
case iPadSoftware
|
case iPadSoftware
|
||||||
case iPhoneSoftware = "software"
|
case iPhoneSoftware = "software"
|
||||||
|
@ -27,7 +28,11 @@ extension StoreSearch {
|
||||||
///
|
///
|
||||||
/// - Parameter appName: MAS app identifier.
|
/// - Parameter appName: MAS app identifier.
|
||||||
/// - Returns: URL for the search service or nil if appName can't be encoded.
|
/// - 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 {
|
guard var components = URLComponents(string: "https://itunes.apple.com/search") else {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,17 +18,16 @@ public class MasStoreSearchSpec: QuickSpec {
|
||||||
}
|
}
|
||||||
describe("url string") {
|
describe("url string") {
|
||||||
it("contains the app name") {
|
it("contains the app name") {
|
||||||
let appName = "myapp"
|
|
||||||
expect {
|
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") {
|
it("contains the encoded app name") {
|
||||||
expect {
|
expect {
|
||||||
MasStoreSearch().searchURL(for: "My App", inCountry: "US")?.absoluteString
|
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") {
|
describe("store") {
|
||||||
|
|
Loading…
Reference in a new issue