Related off of the above question. I'm using mockwebserver and creating my own dispatcher. Which originally was a really simple when statement, but now I'm dealing with api calls that have url params and I feel like I'm missing something basic in order to get something like "wildcards" working correctly.
instead of hard coding the arg. Or maybe there's another way I should go about this. e.g. Only get the path without the args, and then if I need the args I can drill down and get them from the request if need be? Thoughts?
I didn't find anything into OkHttp to parse a recorded path into path + queryParams + fragment but I guess you could also prepend "http://example.com/" and use
toHttpUrl()
j
jw
07/12/2021, 11:48 AM
Or use Android's Uri or the JDK's URI to do it
c
Colton Idle
07/12/2021, 12:07 PM
Ooh. Yeah regex sounds doable. And okay I will look up URI and see what it offers. Cheers
Colton Idle
07/13/2021, 4:46 AM
Thanks for the tip on the JDKs URI class. This did the trick. Especially helpful since my dispatcher is in a java only module. Cheers
Copy code
val asdf = URI.create(request.path!!)
when (asdf.path) {
...