Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(auth): Android Intent URI Query Parameter Parsing #4546

Merged
merged 5 commits into from
Apr 25, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import io.flutter.embedding.engine.plugins.FlutterPlugin
import io.flutter.embedding.engine.plugins.activity.ActivityAware
import io.flutter.embedding.engine.plugins.activity.ActivityPluginBinding
import io.flutter.plugin.common.PluginRegistry
import java.net.URLDecoder
import java.util.Locale

open class AmplifyAuthCognitoPlugin :
Expand Down Expand Up @@ -590,15 +591,22 @@ open class AmplifyAuthCognitoPlugin :
}

}

/**
* The query parameters of the URI.
*/
val Uri.queryParameters: MutableMap<String, String>
get() {
val queryParameters = mutableMapOf<String, String>()
for (name in queryParameterNames) {
queryParameters[name] = getQueryParameter(name) ?: ""
val queryString = this.encodedQuery ?: return queryParameters
val queries = queryString.split("&")

for (query in queries) {
val idx = query.indexOf("=")
if (idx != -1) {
val name = URLDecoder.decode(query.substring(0, idx), "UTF-8")
val value = URLDecoder.decode(query.substring(idx + 1), "UTF-8")
queryParameters[name] = value
}
}
return queryParameters
}
Expand Down
Loading