Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Template all base urls in Globals.js #511

Merged
merged 10 commits into from Apr 14, 2020

template all FQDNs in globals

  • Loading branch information
fcjr committed Mar 17, 2020
commit fd3f6f93626c7d8d50712d60811e529c3385ffed
@@ -36,7 +36,7 @@ const HomeView = (props) => {
email,
isPlus,
} = props;
const accountHref = `https://account.${globals.GHOSTERY_DOMAIN}.com`;
const accountHref = globals.ACCOUNT_FQDN;

let headerInfoText = t('hub_home_header_info');
if (globals.BROWSER_INFO) {
@@ -29,7 +29,7 @@ class PlusView extends Component {
*/
_renderButton = (additionalClasses) => {
const { isPlus, onPlusClick } = this.props;
const buttonHref = `https://checkout.${globals.GHOSTERY_DOMAIN}.com/plus?utm_source=gbe&utm_campaign=intro_hub_plus`;
const buttonHref = `${globals.CHECKOUT_FQDN}/plus?utm_source=gbe&utm_campaign=intro_hub_plus`;
const buttonClassNames = ClassNames('PlusView__button', 'button', additionalClasses, {
disabled: isPlus,
});
@@ -57,7 +57,7 @@ class SideNavigationViewContainer extends Component {
{ href: '/products', icon: 'products', text: t('hub_side_navigation_products') }
];
const bottomItems = user ? [
{ id: 'email', href: `https://account.${globals.GHOSTERY_DOMAIN}.com/`, text: user.email },
{ id: 'email', href: `${globals.ACCOUNT_FQDN}/`, text: user.email },
{ id: 'logout', text: t('sign_out'), clickHandler: this._handleLogoutClick },
] : [
{ id: 'create-account', href: '/create-account', text: t('create_account') },
@@ -56,7 +56,7 @@ class GlobalTracker extends React.Component {
this.setState({ description: t('tracker_description_getting') });

sendMessageInPromise('getTrackerDescription', {
url: `https://${globals.APPS_SUB_DOMAIN}.ghostery.com/${this.props.language}/apps/${
url: `${globals.APPS_FQDN}/${this.props.language}/apps/${
encodeURIComponent(tracker.name.replace(/\s+/g, '_').toLowerCase())}?format=json`,
}).then((data) => {
if (data) {
@@ -114,7 +114,7 @@ class GlobalTracker extends React.Component {
{
this.state.showTrackerLearnMore && (
<div className={(!this.state.showTrackerLearnMore ? 'hide' : '')}>
<a target="_blank" rel="noopener noreferrer" title={tracker.name} href={`https://${globals.APPS_SUB_DOMAIN}.ghostery.com/${this.props.language}/apps/${encodeURIComponent(tracker.name.replace(/\s+/g, '_').toLowerCase())}`}>
<a target="_blank" rel="noopener noreferrer" title={tracker.name} href={`${globals.APPS_FQDN}/${this.props.language}/apps/${encodeURIComponent(tracker.name.replace(/\s+/g, '_').toLowerCase())}`}>
{ t('tracker_description_learn_more') }
</a>
</div>
@@ -89,7 +89,7 @@ class Tracker extends React.Component {
this.setState({ description: t('tracker_description_getting') });

sendMessageInPromise('getTrackerDescription', {
url: `https://${globals.APPS_SUB_DOMAIN}.ghostery.com/${this.props.language}/apps/${
url: `${globals.APPS_FQDN}/${this.props.language}/apps/${
encodeURIComponent(tracker.name.replace(/\s+/g, '_').toLowerCase())}?format=json`,
}).then((data) => {
if (data) {
@@ -304,7 +304,7 @@ class Tracker extends React.Component {
className="trk-src-link"
title={source.src}
key={index}
href={`https://${encodeURIComponent(globals.GCACHE_SUB_DOMAIN)}.ghostery.com/${encodeURIComponent(this.props.language)}/gcache/?n=${encodeURIComponent(tracker.name)}&s=${encodeURIComponent(source.src)}&v=2&t=${source.type}`}
href={`${encodeURIComponent(globals.GCACHE_FQDN)}/${encodeURIComponent(this.props.language)}/gcache/?n=${encodeURIComponent(tracker.name)}&s=${encodeURIComponent(source.src)}&v=2&t=${source.type}`}
>
{ source.src }
</a>
@@ -357,7 +357,7 @@ class Tracker extends React.Component {
<div className="trk-description">
{this.state.description}
<div className={(!this.state.showTrackerLearnMore ? 'hide' : '')}>
<a target="_blank" rel="noopener noreferrer" title={tracker.name} href={`https://${globals.APPS_SUB_DOMAIN}.ghostery.com/${this.props.language}/apps/${encodeURIComponent(tracker.name.replace(/\s+/g, '_').toLowerCase())}`}>
<a target="_blank" rel="noopener noreferrer" title={tracker.name} href={`${globals.APPS_FQDN}/${this.props.language}/apps/${encodeURIComponent(tracker.name.replace(/\s+/g, '_').toLowerCase())}`}>
{t('tracker_description_learn_more')}
</a>
</div>
@@ -126,7 +126,7 @@ class HeaderMenu extends React.Component {
*/
clickSignedInAs = () => {
sendMessage('openNewTab', {
url: `https://account.${globals.GHOSTERY_DOMAIN}.com/`,
url: `${globals.ACCOUNT_FQDN}/`,
become_active: true,
});
window.close();
@@ -37,7 +37,7 @@ class Account extends React.Component {
*/
clickEditAccount = () => {
sendMessage('openNewTab', {
url: `https://account.${globals.GHOSTERY_DOMAIN}.com/`,
url: `${globals.GHOSTERY_ACCOUNT_FQDN}/`,
become_active: true,
});
window.close();
@@ -64,11 +64,11 @@ const { sendMessage } = utils;
const { onMessage } = chrome.runtime;
// simple consts
const {
CDN_SUB_DOMAIN, BROWSER_INFO, IS_CLIQZ, DEBUG
CDN_FQDN, BROWSER_INFO, IS_CLIQZ, DEBUG
} = globals;
const IS_EDGE = (BROWSER_INFO.name === 'edge');
const IS_FIREFOX = (BROWSER_INFO.name === 'firefox');
const VERSION_CHECK_URL = `https://${CDN_SUB_DOMAIN}.ghostery.com/update/version`;
const VERSION_CHECK_URL = `${CDN_FQDN}/update/version`;
const REAL_ESTATE_ID = 'ghostery';
const onBeforeRequest = events.onBeforeRequest.bind(events);
const onHeadersReceived = events.onHeadersReceived.bind(events);
@@ -845,11 +845,11 @@ function onMessageHandler(request, sender, callback) {
return true;
}
if (name === 'account.openSubscriptionPage') {
utils.openNewTab({ url: `https://account.${globals.GHOSTERY_DOMAIN}.com/subscription`, become_active: true });
utils.openNewTab({ url: `${globals.CHECKOUT_FQDN}/subscription`, become_active: true });
return false;
}
if (name === 'account.openCheckoutPage') {
let url = `https://checkout.${globals.GHOSTERY_DOMAIN}.com/plus`;
let url = `${globals.CHECKOUT_FQDN}/plus`;
const { utm } = message || null;
if (utm) {
url += `?utm_source=${utm.utm_source}&utm_campaign=${utm.utm_campaign}`;
@@ -860,7 +860,7 @@ function onMessageHandler(request, sender, callback) {
if (name === 'account.openSupportPage') {
metrics.ping('priority_support_submit');
const subscriber = account.hasScopesUnverified(['subscriptions:plus']);
const tabUrl = subscriber ? `https://account.${globals.GHOSTERY_DOMAIN}.com/support` : 'https://www.ghostery.com/support/';
const tabUrl = subscriber ? `${globals.ACCOUNT_FQDN}/support` : 'https://www.ghostery.com/support/';
utils.openNewTab({ url: tabUrl, become_active: true });
return false;
}
@@ -19,7 +19,7 @@ import globals from './Globals';
import { getJson } from '../utils/utils';
import { log } from '../utils/common';

const { BROWSER_INFO, CMP_SUB_DOMAIN, EXTENSION_VERSION } = globals;
const { BROWSER_INFO, CMP_FQDN, EXTENSION_VERSION } = globals;

/** Helper class for handling A/B tests.
* @memberof BackgroundClasses
@@ -44,7 +44,7 @@ class ABTest {
fetch() {
log('A/B Tests: fetching...');

const URL = `https://${CMP_SUB_DOMAIN}.ghostery.com/abtestcheck
const URL = `${CMP_FQDN}/abtestcheck
?os=${encodeURIComponent(BROWSER_INFO.os)}
&install_date=${encodeURIComponent(conf.install_date)}
&ir=${encodeURIComponent(conf.install_random_number)}
@@ -16,7 +16,7 @@ import globals from './Globals';
import { getJson } from '../utils/utils';
import { log } from '../utils/common';

const { BROWSER_INFO, CMP_SUB_DOMAIN, EXTENSION_VERSION } = globals;
const { BROWSER_INFO, CMP_FQDN, EXTENSION_VERSION } = globals;

/**
* Class for handling notification and/or marketing campaigns.
@@ -36,7 +36,7 @@ class CMP {
return Promise.resolve(false);
}

const URL = `https://${CMP_SUB_DOMAIN}.ghostery.com/check
const URL = `${CMP_FQDN}/check
?os=${encodeURIComponent(BROWSER_INFO.os)}
&offers=${encodeURIComponent(conf.enable_offers ? '1' : '0')}
&hw=${encodeURIComponent(conf.enable_human_web ? '1' : '0')}
@@ -51,15 +51,19 @@ class Globals {

// domains
this.GHOSTERY_DOMAIN = this.DEBUG ? 'ghosterystage' : 'ghostery';
this.METRICS_SUB_DOMAIN = this.DEBUG ? 'staging-d' : 'd';
this.CMP_SUB_DOMAIN = this.DEBUG ? 'staging-cmp-cdn' : 'cmp-cdn';
this.CDN_SUB_DOMAIN = this.DEBUG ? 'staging-cdn' : 'cdn';
this.APPS_SUB_DOMAIN = this.DEBUG ? 'staging-apps' : 'apps';
this.GCACHE_SUB_DOMAIN = this.DEBUG ? 'staging-gcache' : 'gcache';
this.AUTH_SERVER = `https://consumerapi.${this.GHOSTERY_DOMAIN}.com`;
this.ACCOUNT_SERVER = `https://accountapi.${this.GHOSTERY_DOMAIN}.com`;
this.COOKIE_DOMAIN = `.${this.GHOSTERY_DOMAIN}.com`;
this.COOKIE_URL = `https://${this.GHOSTERY_DOMAIN}.com`;
this.GHOSTERY_ROOT_DOMAIN = `${this.GHOSTERY_DOMAIN}.com`;
this.GHOSTERY_FQDN = `https://${this.GHOSTERY_ROOT_DOMAIN}`;
this.ACCOUNT_FQDN = `https://account.${this.GHOSTERY_ROOT_DOMAIN}`;
this.CHECKOUT_FQDN = `https://checkout.${this.GHOSTERY_ROOT_DOMAIN}`;
this.METRICS_FQDN = `https://${this.DEBUG ? 'staging-d' : 'd'}.${this.GHOSTERY_ROOT_DOMAIN}`;
this.CMP_FQDN = `https://${this.DEBUG ? 'staging-cmp-cdn' : 'cmp-cdn'}.${this.GHOSTERY_ROOT_DOMAIN}`;
this.CDN_FQDN = `https://${this.DEBUG ? 'staging-cdn' : 'cdn'}.${this.GHOSTERY_ROOT_DOMAIN}`;
this.APPS_FQDN = `https://${this.DEBUG ? 'staging-apps' : 'apps'}.${this.GHOSTERY_ROOT_DOMAIN}`;
this.GCACHE_FQDN = `https://${this.DEBUG ? 'staging-gcache' : 'gcache'}.${this.GHOSTERY_ROOT_DOMAIN}`;
this.AUTH_SERVER = `https://consumerapi.${this.GHOSTERY_ROOT_DOMAIN}`;
this.ACCOUNT_SERVER = `https://accountapi.${this.GHOSTERY_ROOT_DOMAIN}`;
this.COOKIE_DOMAIN = `.${this.GHOSTERY_ROOT_DOMAIN}`;
this.COOKIE_URL = this.GHOSTERY_FQDN;

// extension IDs
this.GHOSTERY_TAB_CHROME_PRODUCTION_ID = 'plmapebanmikcofllaaddgeocahboejc';
@@ -25,7 +25,7 @@ const FREQUENCIES = { // in milliseconds
};
const CRITICAL_METRICS = ['install', 'install_complete', 'upgrade', 'active', 'engaged', 'uninstall'];
const CAMPAIGN_METRICS = ['install', 'active', 'uninstall'];
const { METRICS_SUB_DOMAIN, EXTENSION_VERSION, BROWSER_INFO } = globals;
const { METRICS_FQDN, EXTENSION_VERSION, BROWSER_INFO } = globals;
const MAX_DELAYED_PINGS = 100;

// Note that this threshold is intentionally different from the 30 second threshold in PolicySmartBlock,
@@ -299,7 +299,7 @@ class Metrics {
_buildMetricsUrl(type, frequency) {
const frequencyString = (type !== 'uninstall') ? `/${frequency}` : '';

let metrics_url = `https://${METRICS_SUB_DOMAIN}.ghostery.com/${type}${frequencyString}?gr=-1` +
let metrics_url = `${METRICS_FQDN}/${type}${frequencyString}?gr=-1` +
// Old parameters, old names
// Human web
`&hw=${encodeURIComponent(conf.enable_human_web ? '1' : '0')}` +
@@ -17,7 +17,7 @@ import conf from './Conf';
import { getJson, fetchLocalJSONResource } from '../utils/utils';
import { log } from '../utils/common';

const { CDN_SUB_DOMAIN } = globals;
const { CDN_FQDN } = globals;
/**
* Base class for BugDb, Click2PlayDb, CompatibilityDb and SurrogateDb.
* It provides update functionality, which all of these subclasses
@@ -131,7 +131,7 @@ class Updatable {
*/
_remoteFetcher(callback) {
log(`fetching ${this.type} from remote`);
const UPDATE_URL = `https://${CDN_SUB_DOMAIN}.ghostery.com/update/${
const UPDATE_URL = `${CDN_FQDN}/update/${
this.type === 'bugs' ? 'v3/bugs' : this.type}`;

getJson(UPDATE_URL).then((list) => {
@@ -130,7 +130,7 @@ export function buildRedirectC2P(requestId, redirectUrls, app_id) {
'blocked_redirect_prevent',
// It is unlikely that apps pages will ever be translated
// [host_url, redirect_url, app_name, 'https://' + globals.APPS_SUB_DOMAIN + '.ghostery.com/' + conf.language + '/apps/' + encodeURIComponent(app_name.replace(/\s+/g, '_').toLowerCase())]),
[host_url, redirect_url, app_name, `https://${globals.APPS_SUB_DOMAIN}.ghostery.com/en/apps/${encodeURIComponent(app_name.replace(/\s+/g, '_').toLowerCase())}`]
[host_url, redirect_url, app_name, `${globals.APPS_FQDN}/en/apps/${encodeURIComponent(app_name.replace(/\s+/g, '_').toLowerCase())}`]
),
blocked_redirect_action_always_title: t('blocked_redirect_action_always_title'),
blocked_redirect_action_through_once_title: t('blocked_redirect_action_through_once_title'),
ProTip! Use n and p to navigate between commits in a pull request.