File tree Expand file tree Collapse file tree 4 files changed +39
-5
lines changed
androidTest/java/com/duckduckgo/app/global
main/java/com/duckduckgo/app/global Expand file tree Collapse file tree 4 files changed +39
-5
lines changed Original file line number Diff line number Diff line change 1717package com.duckduckgo.app.global
1818
1919import android.net.Uri
20+ import androidx.core.net.toUri
2021import org.junit.Assert.*
2122import 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}
Original file line number Diff line number Diff 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
8586fun 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}
Original file line number Diff line number Diff line change 11## What's new in this release?
22Now 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.
34Bug 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 .
Original file line number Diff line number Diff line change 1- VERSION =5.58.0
1+ VERSION =5.58.1
You can’t perform that action at this time.
0 commit comments