Add media=software query item to lookup URL to improve results.

Reorder query items for both lookup URLs & search URLs.

Partial #561

Signed-off-by: Ross Goldberg <484615+rgoldberg@users.noreply.github.com>
This commit is contained in:
Ross Goldberg 2024-10-14 16:29:47 -04:00
parent 6c5a277ad9
commit 280b38dfe8
No known key found for this signature in database
2 changed files with 7 additions and 4 deletions

View file

@ -40,13 +40,14 @@ extension StoreSearch {
components.queryItems = [ components.queryItems = [
URLQueryItem(name: "media", value: "software"), URLQueryItem(name: "media", value: "software"),
URLQueryItem(name: "entity", value: entity.rawValue), URLQueryItem(name: "entity", value: entity.rawValue),
URLQueryItem(name: "term", value: appName),
] ]
if let country { if let country {
components.queryItems!.append(URLQueryItem(name: "country", value: country)) components.queryItems!.append(URLQueryItem(name: "country", value: country))
} }
components.queryItems!.append(URLQueryItem(name: "term", value: appName))
return components.url return components.url
} }
@ -60,7 +61,7 @@ extension StoreSearch {
} }
components.queryItems = [ components.queryItems = [
URLQueryItem(name: "id", value: "\(appID)"), URLQueryItem(name: "media", value: "software"),
URLQueryItem(name: "entity", value: "desktopSoftware"), URLQueryItem(name: "entity", value: "desktopSoftware"),
] ]
@ -68,6 +69,8 @@ extension StoreSearch {
components.queryItems!.append(URLQueryItem(name: "country", value: country)) components.queryItems!.append(URLQueryItem(name: "country", value: country))
} }
components.queryItems!.append(URLQueryItem(name: "id", value: "\(appID)"))
return components.url return components.url
} }
} }

View file

@ -21,13 +21,13 @@ public class MasStoreSearchSpec: QuickSpec {
expect { expect {
MasStoreSearch().searchURL(for: "myapp", inCountry: "US")?.absoluteString 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") { 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=desktopSoftware&term=My%20App&country=US" == "https://itunes.apple.com/search?media=software&entity=desktopSoftware&country=US&term=My%20App"
} }
} }
describe("store") { describe("store") {