Skip to content

Commit 2ec2915

Browse files
authored
Merge pull request #22 from o-vitaliy/master
Fix concatenating multiple query params
2 parents c083212 + 019b790 commit 2ec2915

File tree

2 files changed

+3
-7
lines changed
  • sample/mpp-library/src/commonMain/kotlin/com/icerockdev/library
  • socket-io/src/commonJvm/kotlin/dev/icerock/moko/socket

2 files changed

+3
-7
lines changed

sample/mpp-library/src/commonMain/kotlin/com/icerockdev/library/Testing.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class Testing {
1212
val socket = Socket(
1313
endpoint = "https://socketio-chat-h9jt.herokuapp.com",
1414
config = SocketOptions(
15-
queryParams = null,
15+
queryParams = mapOf("param1" to "1", "param2" to "2"),
1616
transport = SocketOptions.Transport.WEBSOCKET
1717
)
1818
) {

socket-io/src/commonJvm/kotlin/dev/icerock/moko/socket/Socket.kt

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,8 @@ actual class Socket actual constructor(
3333
query = config?.queryParams?.run {
3434
if (size == 0) return@run null
3535

36-
var result = ""
37-
forEach { (key, value) ->
38-
result += "$key=$value"
39-
}
40-
41-
result
36+
val params = map { (key, value) -> "$key=$value"}
37+
params.joinToString("&")
4238
}
4339
})
4440

0 commit comments

Comments
 (0)