Skip to content

Commit 0ac84df

Browse files
committed
8015 Provide query items in priority order
This adds a workaround for an apparent backend bug: only the first query item is used in the `with_query_string` rule. For that reason, we send `build_type` first, followed by `platform`, followed by alphabetical order.
1 parent c7026ac commit 0ac84df

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

Networking/Networking/Remote/JustInTimeMessagesRemote.swift

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,23 @@ public final class JustInTimeMessagesRemote: Remote, JustInTimeMessagesRemotePro
6262
URLQueryItem(name: key, value: value)
6363
}
6464
var components = URLComponents()
65-
components.queryItems = queryItems
65+
/// This is a workaround for a backend bug where only the first param can be used for targeting JITMs.
66+
/// `build_type` is the most important, but absent in release builds. In release builds, `platform` is the most important
67+
/// This can be removed when the backend bug is fixed, order should not matter here.
68+
components.queryItems = queryItems.sorted(by: { lhs, rhs in
69+
switch (lhs.name, rhs.name) {
70+
case (_, "build_type"):
71+
return false
72+
case ("build_type", "platform"):
73+
return true
74+
case (_, "platform"):
75+
return false
76+
case ("platform", _):
77+
return true
78+
default:
79+
return lhs.name < rhs.name
80+
}
81+
})
6682
return components.query
6783
}
6884

0 commit comments

Comments
 (0)