diff --git a/src/common/appId.js b/src/common/appId.js index 272ab0c207..6a77f2dcf0 100644 --- a/src/common/appId.js +++ b/src/common/appId.js @@ -7,7 +7,7 @@ import { get as getStorage, set as setStorage, } from '../common/utils/storageManager'; -import { parseQueryString, isProduction } from '../common/utils/tools'; +import { parseQueryString, isProduction, getExtension } from '../common/utils/tools'; import { getLanguage } from './lang'; import AppIdMap from './appIdResolver'; @@ -77,8 +77,6 @@ export const getDefaultEndpoint = () => ({ appId: getStorage('config.default_app_id') || getDomainAppId() || 1169, }); -export const getExtension = () => hostName.split('.').slice(-1)[0]; - const generateOAuthDomain = () => { const endpointUrl = getCustomEndpoint().url; if (endpointUrl) { diff --git a/src/common/utils/tools.js b/src/common/utils/tools.js index b3748631d3..6d61978926 100644 --- a/src/common/utils/tools.js +++ b/src/common/utils/tools.js @@ -51,14 +51,28 @@ export const durationToSecond = duration => { export const isProduction = () => document.location.hostname.replace(/^www./, '') in AppIdMap; -export const createUrl = (path, lang = getLanguage(), addLanguage = true, addHtmlExtension = true) => { - const pathBit = path ? `/${path}${addHtmlExtension ? '.html' : ''}` : ''; - const languageBit = addLanguage && lang ? `/${lang}` : ''; - +export const createUrl = options => { + const getOption = property => Object.prototype.hasOwnProperty.call(options, property) && options[property]; + const language = getOption('addLanguage') ? `/${getLanguage()}` : ''; + const path = getOption('path') ? `/${getOption('path')}` : ''; + const htmlExtension = getOption('addHtmlExtension') ? '.html' : ''; + const subdomain = getOption('subdomain') ? `${getOption('subdomain')}.` : 'www.'; if (isProduction()) { - return `${document.location.protocol}//${document.location.hostname}${languageBit}${pathBit}`; + let domainExtension = `.${getExtension()}`; + if (getOption('isNonBotPage')) { + switch (document.location.hostname.replace(/^www./, '')) { + case 'bot.binary.me': + case 'binary.bot': + domainExtension = '.me'; + break; + default: + domainExtension = '.com'; + break; + } + } + return `${document.location.protocol}//${subdomain}binary${domainExtension}${language}${path}${htmlExtension}`; } - return `https://www.binary.com${languageBit}${pathBit}`; + return `https://${subdomain}binary.com${language}${path}${htmlExtension}`; }; export const translate = input => { @@ -74,3 +88,9 @@ export const translate = input => { } return i18nTranslate(input); }; + +export const getExtension = () => { + const host = document.location.hostname; + const extension = host.split('.').slice(-1)[0]; + return host !== extension ? extension : ''; +}; diff --git a/src/indexPage/index.js b/src/indexPage/index.js index 44ab0cf1db..1786b95441 100644 --- a/src/indexPage/index.js +++ b/src/indexPage/index.js @@ -4,8 +4,8 @@ import ReactDOM from 'react-dom'; import Logo from './react-components/logo.jsx'; import Footer from './react-components/footer.jsx'; import { getTokenList } from '../common/utils/storageManager'; -import { oauthLogin, getExtension } from '../common/appId'; -import { isProduction } from '../common/utils/tools'; +import { oauthLogin } from '../common/appId'; +import { createUrl } from '../common/utils/tools'; import { load as loadLang } from '../common/lang'; import '../common/binary-ui/dropdown'; import endpoint from './endpoint'; @@ -21,11 +21,7 @@ const renderElements = () => { isEuCountry().then(isEu => { showHideEuElements(isEu); }); - const domainExtension = getExtension(); - const shopUrl = `https://shop.binary.${ - isProduction() ? (domainExtension === 'bot' ? 'com' : domainExtension) : 'com' - }/collections/strategies`; - $('#shop-url').attr('href', shopUrl); + $('#shop-url').attr('href', createUrl({ subdomain: 'shop', path: 'collections/strategies', isNonBotPage: true })); }; const loginCheck = () => { diff --git a/src/indexPage/react-components/footer.jsx b/src/indexPage/react-components/footer.jsx index e575f15bc3..3b81758d7e 100644 --- a/src/indexPage/react-components/footer.jsx +++ b/src/indexPage/react-components/footer.jsx @@ -19,15 +19,15 @@ const Footer = () => (
- {translate(['In the EU, financial products are offered by Binary Investments (Europe) Ltd., Mompalao Building, Suite 2, Tower Road, Msida MSD1825, Malta, regulated as a Category 3 Investment Services provider by the Malta Financial Services Authority ([_1]licence no. IS/70156[_2]).', ``, ''])} + {translate(['In the EU, financial products are offered by Binary Investments (Europe) Ltd., Mompalao Building, Suite 2, Tower Road, Msida MSD1825, Malta, regulated as a Category 3 Investment Services provider by the Malta Financial Services Authority ([_1]licence no. IS/70156[_2]).', ``, ''])}
{translate(['Outside the EU, financial products are offered by Binary (C.R.) S.A., 5th Floor, Building 6 Centro Ejecutivo La Sabana, Sabana Sur, San José, Costa Rica, Binary (V) Ltd, Govant Building, Port Vila, PO Box 1276, Vanuatu, regulated by the Vanuatu Financial Services Commission ([_1]view licence[_2]), Binary (BVI) Ltd, 2nd Floor, O’Neal Marketing Associates Building, Wickham’s Cay II, P.O. Box 3174, Road Town, Tortola VB1110, British Virgin Islands, regulated by the British Virgin Islands Financial Services Commission ([_3]licence no. SIBA/L/18/1114[_4]), and Binary (FX) Ltd., Lot No. F16, First Floor, Paragon Labuan, Jalan Tun Mustapha, 87000 Labuan, Malaysia, regulated by the Labuan Financial Services Authority to carry on a money-broking business ([_5]licence no. MB/18/0024[_6])', '', '', - ``, '', - ``, ''])} + ``, '', + ``, ''])}
{translate(['This website’s services are not made available in certain countries such as the USA, Canada, Costa Rica, Hong Kong, Japan, or to persons under age 18.'])}
- {translate(['In the rest of the EU, Volatility Indices are offered by Binary (Europe) Ltd., Mompalao Building, Suite 2, Tower Road, Msida MSD1825, Malta; licensed and regulated by (1) the Malta Gaming Authority in Malta (licence no. MGA/B2C/102/2000 issued on 01 August 2018), for UK clients by (2) the UK Gambling Commission (licence [_1]reference no: 39495[_2]), and for Irish clients by (3) the Revenue Commissioners in Ireland (Remote Bookmaker\'s Licence no. 1010285 issued on 1 July 2017). View complete [_3]Regulatory Information[_2].', '', '', ``])} + {translate(['In the rest of the EU, Volatility Indices are offered by Binary (Europe) Ltd., Mompalao Building, Suite 2, Tower Road, Msida MSD1825, Malta; licensed and regulated by (1) the Malta Gaming Authority in Malta (licence no. MGA/B2C/102/2000 issued on 01 August 2018), for UK clients by (2) the UK Gambling Commission (licence [_1]reference no: 39495[_2]), and for Irish clients by (3) the Revenue Commissioners in Ireland (Remote Bookmaker\'s Licence no. 1010285 issued on 1 July 2017). View complete [_3]Regulatory Information[_2].', '', '', ``])}
- {translate(['Binary.com is an award-winning online trading provider that helps its clients to trade on financial markets through binary options and CFDs. Trading binary options and CFDs on Volatility Indices is classified as a gambling activity. Remember that gambling can be addictive – please play responsibly. Learn more about [_1]Responsible Trading[_2]. Some products are not available in all countries. This website’s services are not made available in certain countries such as the USA, Canada, Costa Rica, Hong Kong, or to persons under age 18.', ``, ''])} + {translate(['Binary.com is an award-winning online trading provider that helps its clients to trade on financial markets through binary options and CFDs. Trading binary options and CFDs on Volatility Indices is classified as a gambling activity. Remember that gambling can be addictive – please play responsibly. Learn more about [_1]Responsible Trading[_2]. Some products are not available in all countries. This website’s services are not made available in certain countries such as the USA, Canada, Costa Rica, Hong Kong, or to persons under age 18.', ``, ''])}