android / android-ktx

A set of Kotlin extensions for Android app development.
https://android.github.io/android-ktx/core-ktx/
7.47k stars 563 forks source link

Adding URI encoding and decoding extensions #534

Closed RamV13 closed 6 years ago

RamV13 commented 6 years ago

Before:

val string = "http%3A%2F%2Ftest.example.com%2Ffoo%20bar"
val decoded = Uri.decode(string)
val encoded = Uri.encode(decoded)

After:

val string = "http%3A%2F%2Ftest.example.com%2Ffoo%20bar"
val decoded = string.decode()
val encoded = string.encode()
rharter commented 6 years ago

This seems rather specific. From the API it's unclear what is being encoded or decoded. string.decode() doesn't indicate that this should decoded a URI vs. MD5 vs. SHA-1...

IMHO the Uri.decode(string) is a clearer API and the same amount of code so what's the added benefit of this?

RamV13 commented 6 years ago

Agreed