Skip to content

Commit

Permalink
feat(android): 기본 userAgent에 source에서 전달받은 user agent를 추가하도록 함
Browse files Browse the repository at this point in the history
  • Loading branch information
ujeon committed Apr 17, 2024
1 parent b665453 commit 0b40215
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,7 @@ class RNCWebViewManagerImpl {
return
}
if (source.hasKey("uri")) {
val defaultUserAgent = WebSettings.getDefaultUserAgent(view.context)
val url = source.getString("uri")
val previousUrl = view.url
if (previousUrl != null && previousUrl == url) {
Expand Down Expand Up @@ -451,7 +452,7 @@ class RNCWebViewManagerImpl {
val name = headerCasted.get("name") ?: ""
val value = headerCasted.get("value") ?: ""
if ("user-agent" == name.lowercase(Locale.ENGLISH)) {
view.settings.userAgentString = value
view.settings.userAgentString = "$defaultUserAgent $value"
} else {
headerMap[name] = value
}
Expand All @@ -462,7 +463,8 @@ class RNCWebViewManagerImpl {
while (iter.hasNextKey()) {
val key = iter.nextKey()
if ("user-agent" == key.lowercase(Locale.ENGLISH)) {
view.settings.userAgentString = headers.getString(key)
val customUserAgent = headers.getString(key)
view.settings.userAgentString = "$defaultUserAgent $customUserAgent"
} else {
headerMap[key] = headers.getString(key)
}
Expand Down

0 comments on commit 0b40215

Please sign in to comment.