Skip to content

Commit cc37ab6

Browse files
committed
Merge tag '5.58.1' into develop
no message
2 parents b2131d7 + bb7c0c0 commit cc37ab6

File tree

4 files changed

+39
-5
lines changed

4 files changed

+39
-5
lines changed

app/src/androidTest/java/com/duckduckgo/app/global/UriExtensionTest.kt

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
package com.duckduckgo.app.global
1818

1919
import android.net.Uri
20+
import androidx.core.net.toUri
2021
import org.junit.Assert.*
2122
import org.junit.Test
2223

@@ -194,4 +195,33 @@ class UriExtensionTest {
194195
val absoluteString = Uri.parse("https://example.com/test?q=example/#1/anotherrandomcode").absoluteString
195196
assertEquals("https://example.com/test", absoluteString)
196197
}
198+
199+
@Test
200+
fun whenNullUrlThenNullFaviconUrl() {
201+
assertNull("".toUri().faviconLocation())
202+
}
203+
204+
@Test
205+
fun whenHttpRequestThenFaviconLocationAlsoHttp() {
206+
val favicon = "http://example.com".toUri().faviconLocation()
207+
assertTrue(favicon!!.isHttp)
208+
}
209+
210+
@Test
211+
fun whenHttpsRequestThenFaviconLocationAlsoHttps() {
212+
val favicon = "https://example.com".toUri().faviconLocation()
213+
assertTrue(favicon!!.isHttps)
214+
}
215+
216+
@Test
217+
fun whenUrlContainsASubdomainThenSubdomainReturnedInFavicon() {
218+
val favicon = "https://sub.example.com".toUri().faviconLocation()
219+
assertEquals("https://sub.example.com/favicon.ico", favicon.toString())
220+
}
221+
222+
@Test
223+
fun whenUrlIsIpAddressThenIpReturnedInFaviconUrl() {
224+
val favicon = "https://192.168.1.0".toUri().faviconLocation()
225+
assertEquals("https://192.168.1.0/favicon.ico", favicon.toString())
226+
}
197227
}

app/src/main/java/com/duckduckgo/app/global/UriExtension.kt

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,13 @@ fun Uri.toDesktopUri(): Uri {
8080
return parse(newUrl)
8181
}
8282

83-
private const val faviconBaseUrlFormat = "https://proxy.duckduckgo.com/ip3/%s.ico"
83+
// to obtain a favicon for a website, we go directly to the site and look for /favicon.ico
84+
private const val faviconBaseUrlFormat = "%s://%s/favicon.ico"
8485

8586
fun Uri?.faviconLocation(): Uri? {
86-
val host = this?.host
87+
if (this == null) return null
88+
val host = this.host
8789
if (host.isNullOrBlank()) return null
88-
return parse(String.format(faviconBaseUrlFormat, host))
90+
val isHttps = this.isHttps
91+
return parse(String.format(faviconBaseUrlFormat, if (isHttps) "https" else "http", host))
8992
}

app/version/release-notes

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
## What's new in this release?
22
Now the app can prompt you to Fireproof a site when you sign in. Enable this in Settings > Fireproof Websites.
3+
Retrieve favicons directly from websites.
34
Bug fixes and other improvements.
45

56
## Have feedback?
6-
We've adjusted the color contrast in both light and dark themes to improve visibility.
7+
You can always reach us at https://duckduckgo.com/feedback.

app/version/version.properties

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

0 commit comments

Comments
 (0)