From 0412658df81cd1a3d7347249bc0d066b0f4a2d31 Mon Sep 17 00:00:00 2001 From: Aaron Imming Date: Thu, 20 Dec 2018 10:30:55 +0800 Subject: [PATCH 1/5] Fix createUrl() function --- src/common/appId.js | 4 +--- src/common/utils/tools.js | 23 +++++++++++++++------- src/indexPage/index.js | 4 ++-- src/indexPage/react-components/footer.jsx | 24 +++++++++++------------ src/indexPage/react-components/logo.jsx | 2 +- 5 files changed, 32 insertions(+), 25 deletions(-) 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..cc94ff03e0 100644 --- a/src/common/utils/tools.js +++ b/src/common/utils/tools.js @@ -51,14 +51,17 @@ 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 = (urlSubdomain = false, urlPath, shouldAddLanguage = true, shouldAddHtmlExtension = true) => { + const subdomain = urlSubdomain ? `${urlSubdomain}.` : 'www.'; + const domainExtension = getExtension() ? `.${getExtension()}` : ''; + const language = shouldAddLanguage ? `/${getLanguage()}` : ''; + const path = urlPath ? `/${urlPath}` : ''; + const htmlExtension = shouldAddHtmlExtension ? '.html' : ''; if (isProduction()) { - return `${document.location.protocol}//${document.location.hostname}${languageBit}${pathBit}`; - } - return `https://www.binary.com${languageBit}${pathBit}`; + return `${document.location.protocol}//${subdomain}binary${domainExtension}${language}${path}${htmlExtension}`; + } + return `https://binary.com${language}${path}${htmlExtension}`; + }; export const translate = input => { @@ -74,3 +77,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..e1558f1f14 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 { isProduction, getExtension } from '../common/utils/tools'; import { load as loadLang } from '../common/lang'; import '../common/binary-ui/dropdown'; import endpoint from './endpoint'; diff --git a/src/indexPage/react-components/footer.jsx b/src/indexPage/react-components/footer.jsx index e575f15bc3..7640e1e4f0 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(['Risk Warning'])} -

{translate(['The financial products offered via this website include binary options, contracts for difference ("CFDs") and other complex derivatives and financial products. Trading binary options may not be suitable for everyone. Trading CFDs carries a high level of risk since leverage can work both to your advantage and disadvantage. As a result, the products offered on this website may not be suitable for all investors because of the risk of losing all of your invested capital. You should never invest money that you cannot afford to lose, and never trade with borrowed money. Before trading in the complex financial products offered, please be sure to understand the risks involved and learn about [_1]Responsible Trading[_2].', ``, ''])}

+

{translate(['The financial products offered via this website include binary options, contracts for difference ("CFDs") and other complex derivatives and financial products. Trading binary options may not be suitable for everyone. Trading CFDs carries a high level of risk since leverage can work both to your advantage and disadvantage. As a result, the products offered on this website may not be suitable for all investors because of the risk of losing all of your invested capital. You should never invest money that you cannot afford to lose, and never trade with borrowed money. Before trading in the complex financial products offered, please be sure to understand the risks involved and learn about [_1]Responsible Trading[_2].', ``, ''])}

@@ -102,7 +102,7 @@ const Footer = () => ( {translate(['In the Isle of Man and the UK, Volatility Indices are offered by Binary (IOM) Ltd., First Floor, Millennium House, Victoria Road, Douglas, IM2 4RW, Isle of Man, British Isles; licensed and regulated respectively by (1) the Gambling Supervision Commission in the Isle of Man (current licence issued on 31 August 2017) and by (2) the Gambling Commission in the UK (licence [_1]reference no: 39172[_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(['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].', '', '', ``])}

@@ -110,7 +110,7 @@ const Footer = () => (

- {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.', ``, ''])}

diff --git a/src/indexPage/react-components/logo.jsx b/src/indexPage/react-components/logo.jsx index 0bb08bd4e8..a83fd8720a 100644 --- a/src/indexPage/react-components/logo.jsx +++ b/src/indexPage/react-components/logo.jsx @@ -2,7 +2,7 @@ import React from 'react'; import { createUrl } from '../../common/utils/tools'; const Logo = () => ( -

`, ''])} + {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(['Risk Warning'])} -

{translate(['The financial products offered via this website include binary options, contracts for difference ("CFDs") and other complex derivatives and financial products. Trading binary options may not be suitable for everyone. Trading CFDs carries a high level of risk since leverage can work both to your advantage and disadvantage. As a result, the products offered on this website may not be suitable for all investors because of the risk of losing all of your invested capital. You should never invest money that you cannot afford to lose, and never trade with borrowed money. Before trading in the complex financial products offered, please be sure to understand the risks involved and learn about [_1]Responsible Trading[_2].', ``, ''])}

+

{translate(['The financial products offered via this website include binary options, contracts for difference ("CFDs") and other complex derivatives and financial products. Trading binary options may not be suitable for everyone. Trading CFDs carries a high level of risk since leverage can work both to your advantage and disadvantage. As a result, the products offered on this website may not be suitable for all investors because of the risk of losing all of your invested capital. You should never invest money that you cannot afford to lose, and never trade with borrowed money. Before trading in the complex financial products offered, please be sure to understand the risks involved and learn about [_1]Responsible Trading[_2].', ``, ''])}

+ +
@@ -102,7 +110,7 @@ const Footer = () => ( {translate(['In the Isle of Man and the UK, Volatility Indices are offered by Binary (IOM) Ltd., First Floor, Millennium House, Victoria Road, Douglas, IM2 4RW, Isle of Man, British Isles; licensed and regulated respectively by (1) the Gambling Supervision Commission in the Isle of Man (current licence issued on 31 August 2017) and by (2) the Gambling Commission in the UK (licence [_1]reference no: 39172[_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(['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].', '', '', ``])}

@@ -110,7 +118,7 @@ const Footer = () => (

- {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.', ``, ''])}

diff --git a/src/indexPage/react-components/logo.jsx b/src/indexPage/react-components/logo.jsx index a83fd8720a..25d9d91e0e 100644 --- a/src/indexPage/react-components/logo.jsx +++ b/src/indexPage/react-components/logo.jsx @@ -2,7 +2,7 @@ import React from 'react'; import { createUrl } from '../../common/utils/tools'; const Logo = () => ( -

`, ''])} - -

{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.'])} @@ -65,8 +59,6 @@ const Footer = () => (

{translate(['Risk Warning'])}

{translate(['The financial products offered via this website include binary options, contracts for difference ("CFDs") and other complex derivatives and financial products. Trading binary options may not be suitable for everyone. Trading CFDs carries a high level of risk since leverage can work both to your advantage and disadvantage. As a result, the products offered on this website may not be suitable for all investors because of the risk of losing all of your invested capital. You should never invest money that you cannot afford to lose, and never trade with borrowed money. Before trading in the complex financial products offered, please be sure to understand the risks involved and learn about [_1]Responsible Trading[_2].', ``, ''])}

- -