Any alternative suggestion (more kotlin idiom/func...
# codereview
m
Any alternative suggestion (more kotlin idiom/functional approach) to extract the following string? from:
Copy code
<deeplink scheme>://jobs?category_id=asdf&employment_type=FULLTIME
into a query parameter (what I can think of atm was map):
Copy code
mapOf(
   "category_id" to "asdf",
   "employment_type" to "FULLTIME"
)
my code attempts in 🧵
Copy code
val queries = "<deeplink scheme>://jobs?category_id=asdf&employment_type=FULLTIME"
                        .substringAfter("?")
                        // categorize it into list
                        .split("&")
                        .associate {
                            // "category_id" to "asdf"
                            it.substringBefore("=") to it.substringAfter("=")
                        }
👌 1
s
I would be more worried about URL encoding issues than idiomatic Kotlin; I would use a library for this; e.g.: https://hc.apache.org/httpcomponents-core-5.1.x/5.1.2/apidocs/org/apache/hc/core5/net/URIBuilder.html
✍️ 1
👍 5
m
Turns out. The
android.net.Uri
has
Uri.getQueryParameter("key")
that more convenient in our case, instead of trying to manually parsing this It also has
Uri.getEncodedQuery
today i learned 2