Skip to content

Commit e1951f6

Browse files
committed
fix unsupportedoperationexception due to non hierarchical Uri
1 parent a6bf0b2 commit e1951f6

File tree

3 files changed

+22
-3
lines changed

3 files changed

+22
-3
lines changed

app/src/androidTest/java/com/duckduckgo/app/browser/BrowserTabViewModelTest.kt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1990,6 +1990,12 @@ class BrowserTabViewModelTest {
19901990
assertFalse(browserViewState().showDaxIcon)
19911991
}
19921992

1993+
@Test
1994+
fun whenQueryIsNotHierarchicalThenUnsupportedOperationExceptionIsHandled() {
1995+
whenever(mockOmnibarConverter.convertQueryToUrl("about:blank", null)).thenReturn("about:blank")
1996+
testee.onUserSubmittedQuery("about:blank")
1997+
}
1998+
19931999
private inline fun <reified T : Command> assertCommandIssued(instanceAssertions: T.() -> Unit = {}) {
19942000
verify(mockCommandObserver, atLeastOnce()).onChanged(commandCaptor.capture())
19952001
val issuedCommand = commandCaptor.allValues.find { it is T }

app/src/main/java/com/duckduckgo/app/browser/BrowserTabViewModel.kt

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ import kotlinx.coroutines.Job
103103
import kotlinx.coroutines.launch
104104
import kotlinx.coroutines.withContext
105105
import timber.log.Timber
106+
import java.lang.UnsupportedOperationException
106107
import java.util.Locale
107108
import java.util.concurrent.TimeUnit
108109

@@ -445,8 +446,20 @@ class BrowserTabViewModel(
445446
}
446447

447448
private fun fireQueryChangedPixel(omnibarText: String) {
448-
val oldParameter = currentOmnibarViewState().omnibarText.toUri()?.getQueryParameter(AppUrl.ParamKey.QUERY)
449-
val newParameter = omnibarText.toUri()?.getQueryParameter(AppUrl.ParamKey.QUERY)
449+
val oldUri = currentOmnibarViewState().omnibarText.toUri()
450+
val newUri = omnibarText.toUri()
451+
452+
val oldParameter = try {
453+
oldUri.getQueryParameter(AppUrl.ParamKey.QUERY)
454+
} catch (e: UnsupportedOperationException) {
455+
null
456+
}
457+
val newParameter = try {
458+
newUri.getQueryParameter(AppUrl.ParamKey.QUERY)
459+
} catch (e: UnsupportedOperationException) {
460+
null
461+
}
462+
450463
if (oldParameter == newParameter) {
451464
pixel.fire(String.format(Locale.US, PixelName.SERP_REQUERY.pixelName, PixelParameter.SERP_QUERY_NOT_CHANGED))
452465
} else {

app/version/version.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
VERSION=5.57.0
1+
VERSION=5.57.1

0 commit comments

Comments
 (0)