From 4a90106a83ee9f652eb375eac25a1a630c060944 Mon Sep 17 00:00:00 2001 From: Craig Russell Date: Thu, 2 Jul 2020 14:02:00 +0100 Subject: [PATCH 1/3] Obtain favicons directly from the website instead of a favicon service --- .../duckduckgo/app/global/UriExtensionTest.kt | 30 +++++++++++++++++++ .../com/duckduckgo/app/global/UriExtension.kt | 9 ++++-- 2 files changed, 36 insertions(+), 3 deletions(-) diff --git a/app/src/androidTest/java/com/duckduckgo/app/global/UriExtensionTest.kt b/app/src/androidTest/java/com/duckduckgo/app/global/UriExtensionTest.kt index 85c1ad447f21..6e91ae1d914c 100644 --- a/app/src/androidTest/java/com/duckduckgo/app/global/UriExtensionTest.kt +++ b/app/src/androidTest/java/com/duckduckgo/app/global/UriExtensionTest.kt @@ -17,6 +17,7 @@ package com.duckduckgo.app.global import android.net.Uri +import androidx.core.net.toUri import org.junit.Assert.* import org.junit.Test @@ -194,4 +195,33 @@ class UriExtensionTest { val absoluteString = Uri.parse("https://example.com/test?q=example/#1/anotherrandomcode").absoluteString assertEquals("https://example.com/test", absoluteString) } + + @Test + fun whenNullUrlThenNullFaviconUrl() { + assertNull("".toUri().faviconLocation()) + } + + @Test + fun whenHttpRequestThenFaviconLocationAlsoHttp() { + val favicon = "http://example.com".toUri().faviconLocation() + assertTrue(favicon!!.isHttp) + } + + @Test + fun whenHttpsRequestThenFaviconLocationAlsoHttps() { + val favicon = "https://example.com".toUri().faviconLocation() + assertTrue(favicon!!.isHttps) + } + + @Test + fun whenUrlContainsASubdomainThenSubdomainReturnedInFavicon() { + val favicon = "https://sub.example.com".toUri().faviconLocation() + assertEquals("https://sub.example.com/favicon.ico", favicon.toString()) + } + + @Test + fun whenUrlIsIpAddressThenIpReturnedInFaviconUrl() { + val favicon = "https://192.168.1.0".toUri().faviconLocation() + assertEquals("https://192.168.1.0/favicon.ico", favicon.toString()) + } } diff --git a/app/src/main/java/com/duckduckgo/app/global/UriExtension.kt b/app/src/main/java/com/duckduckgo/app/global/UriExtension.kt index f6245e8a56f7..cffbab7f84ef 100644 --- a/app/src/main/java/com/duckduckgo/app/global/UriExtension.kt +++ b/app/src/main/java/com/duckduckgo/app/global/UriExtension.kt @@ -80,10 +80,13 @@ fun Uri.toDesktopUri(): Uri { return parse(newUrl) } -private const val faviconBaseUrlFormat = "https://proxy.duckduckgo.com/ip3/%s.ico" +// to obtain a favicon for a website, we go directly to the site and look for /favicon.ico +private const val faviconBaseUrlFormat = "%s://%s/favicon.ico" fun Uri?.faviconLocation(): Uri? { - val host = this?.host + if (this == null) return null + val host = this.host if (host.isNullOrBlank()) return null - return parse(String.format(faviconBaseUrlFormat, host)) + val isHttps = this.isHttps + return parse(String.format(faviconBaseUrlFormat, if (isHttps) "https" else "http", host)) } From a0eef6c6ed951d54ffefc7820f87c4ce6e57c998 Mon Sep 17 00:00:00 2001 From: Craig Russell Date: Thu, 2 Jul 2020 14:05:29 +0100 Subject: [PATCH 2/3] Update version number and release notes --- app/version/release-notes | 2 +- app/version/version.properties | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/version/release-notes b/app/version/release-notes index 843a940fda1b..59db0a577ade 100644 --- a/app/version/release-notes +++ b/app/version/release-notes @@ -3,4 +3,4 @@ Now the app can prompt you to Fireproof a site when you sign in. Enable this in Bug fixes and other improvements. ## Have feedback? -We've adjusted the color contrast in both light and dark themes to improve visibility. \ No newline at end of file +You can always reach us at https://duckduckgo.com/feedback. \ No newline at end of file diff --git a/app/version/version.properties b/app/version/version.properties index ec203770de6f..c974adc3303e 100644 --- a/app/version/version.properties +++ b/app/version/version.properties @@ -1 +1 @@ -VERSION=5.58.0 \ No newline at end of file +VERSION=5.58.1 \ No newline at end of file From 244819b698e3d7ddebcc61e8e95e3f3e5fa90c29 Mon Sep 17 00:00:00 2001 From: Craig Russell Date: Thu, 2 Jul 2020 14:33:58 +0100 Subject: [PATCH 3/3] Update release notes --- app/version/release-notes | 1 + 1 file changed, 1 insertion(+) diff --git a/app/version/release-notes b/app/version/release-notes index 59db0a577ade..992caa0f844e 100644 --- a/app/version/release-notes +++ b/app/version/release-notes @@ -1,5 +1,6 @@ ## What's new in this release? Now the app can prompt you to Fireproof a site when you sign in. Enable this in Settings > Fireproof Websites. +Retrieve favicons directly from websites. Bug fixes and other improvements. ## Have feedback?