Skip to content

Commit

Permalink
Disables Wayback Machine infobar on Wayback Machine URLs
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanml committed Dec 30, 2020
1 parent 4b62389 commit bbefe76
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include <string>

#include "base/strings/string_util.h"
#include "brave/components/brave_wayback_machine/url_constants.h"
#include "net/base/url_util.h"
#include "url/gurl.h"

Expand All @@ -21,5 +22,9 @@ bool IsWaybackMachineDisabledFor(const GURL& url) {
if (base::EndsWith(url.host(), ".onion", base::CompareCase::SENSITIVE))
return true;

// Disable on web.archive.org
if (url.host() == kWaybackHost)
return true;

return false;
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
#include "url/gurl.h"

TEST(BraveWaybackMachineUtilsTest, LocalHostDisabledTest) {
EXPECT_TRUE(
IsWaybackMachineDisabledFor(GURL("https://web.archive.org/foobar.html")));
EXPECT_TRUE(IsWaybackMachineDisabledFor(GURL("http://localhost/index.html")));
EXPECT_TRUE(IsWaybackMachineDisabledFor(GURL("http://abcd.local")));
EXPECT_TRUE(IsWaybackMachineDisabledFor(GURL("http://abcd.onion")));
Expand All @@ -18,4 +20,6 @@ TEST(BraveWaybackMachineUtilsTest, LocalHostDisabledTest) {
EXPECT_FALSE(IsWaybackMachineDisabledFor(GURL("http://www.local-news.com")));
EXPECT_FALSE(IsWaybackMachineDisabledFor(GURL("http://www.onion-news.com")));
EXPECT_FALSE(IsWaybackMachineDisabledFor(GURL("http://www.brave.com")));
EXPECT_FALSE(
IsWaybackMachineDisabledFor(GURL("https://archive.org/foobar.html")));
}
1 change: 1 addition & 0 deletions components/brave_wayback_machine/url_constants.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@

const char kWaybackQueryURL[] =
"https://brave-api.archive.org/wayback/available?url=";
const char kWaybackHost[] = "web.archive.org";
1 change: 1 addition & 0 deletions components/brave_wayback_machine/url_constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@
#define BRAVE_COMPONENTS_BRAVE_WAYBACK_MACHINE_URL_CONSTANTS_H_

extern const char kWaybackQueryURL[];
extern const char kWaybackHost[];

#endif // BRAVE_COMPONENTS_BRAVE_WAYBACK_MACHINE_URL_CONSTANTS_H_

0 comments on commit bbefe76

Please sign in to comment.