Skip to content
This repository was archived by the owner on Feb 22, 2024. It is now read-only.

Commit a98509e

Browse files
Cloudflare pages: Fix rendering logic and regex.
1 parent 520cf79 commit a98509e

File tree

4 files changed

+12
-17
lines changed

4 files changed

+12
-17
lines changed

src/botPage/view/View.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -848,12 +848,12 @@ function renderReactComponents() {
848848
const qs = parseQueryString();
849849
if (new Date().getTime() > Number(bannerToken)) {
850850
remove('setDueDateForBanner');
851-
const getDefaultPath = window.location.href.replace('/bot.html', serialize(qs));
851+
const getDefaultPath = window.location.href.replace(/\/bot(\.html)?/, serialize(qs));
852852
window.location.replace(getDefaultPath);
853853
return false;
854854
}
855855
if (bannerToken === null || bannerToken === undefined) {
856-
const getDefaultPath = window.location.href.replace('/bot.html', serialize(qs));
856+
const getDefaultPath = window.location.href.replace(/\/bot(\.html)?/, serialize(qs));
857857
window.location.replace(getDefaultPath);
858858
document.getElementById('errorArea').remove();
859859
$('.barspinner').hide();
@@ -867,7 +867,7 @@ function renderReactComponents() {
867867
!(
868868
typeof window.location !== 'undefined' &&
869869
isProduction() &&
870-
window.location.pathname === '/bot.html'
870+
window.location.pathname.includes('/bot')
871871
)
872872
}
873873
/>,

src/indexPage/endpoint.js

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,13 @@ import { get as getStorage, set as setStorage } from '../common/utils/storageMan
22
import { generateWebSocketURL, getDefaultEndpoint, generateTestLiveApiInstance } from '../common/appId';
33
import { translate } from '../common/i18n';
44

5-
if (document.location.href.endsWith('/endpoint')) {
6-
window.location.replace(`${document.location.href}.html`);
7-
throw new Error('Unexpected URL.'); // To prevent URL replace in index and further execution
8-
}
9-
105
const MessageProperties = {
116
connected: () => `<b>Connected to the Endpoint ${getStorage('config.server_url')}!</b>`,
127
error : () => `Unable to connect to ${getStorage('config.server_url')}. Switching connection to default endpoint.`,
138
};
149

1510
export default function endpoint() {
16-
if (!document.location.href.match(/endpoint\.html/)) return false;
11+
if (!document.location.pathname.includes('/endpoint')) return false;
1712
$(document).ready(() => {
1813
$('#error').hide();
1914
$('#connected').hide();

src/indexPage/index.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ export const setTimeOutBanner = route => {
6464
(route === 'index' && !!bannerDisplayed === false) ||
6565
(route === 'views' && checkifBotRunning() === false)
6666
) {
67-
const getDefaultPath = window.location.href.replace('/bot.html', serialize(qs));
67+
const getDefaultPath = window.location.href.replace(/\/bot(\.html)?/, serialize(qs));
6868
window.location.replace(getDefaultPath);
6969
renderBanner();
7070
} else if (
@@ -79,7 +79,7 @@ export const setTimeOutBanner = route => {
7979
};
8080

8181
export const renderBanner = () => {
82-
if (window.location.href.indexOf('bot.html') === -1 || window.location.pathname === '/movetoderiv.html') {
82+
if (window.location.pathname.indexOf('/bot') === -1 || window.location.pathname === '/movetoderiv.html') {
8383
getComponent();
8484
render(Component, document.getElementById(dynamicRoutePathanme));
8585
if (dynamicRoutePathanme === 'bot-landing') {
@@ -101,7 +101,7 @@ const renderElements = () => {
101101
$('.barspinner').show();
102102

103103
if (!bannerToken) {
104-
if (window.location.href.indexOf('bot.html') === -1) {
104+
if (window.location.pathname.indexOf('/bot') === -1) {
105105
renderBanner();
106106
}
107107
} else {
@@ -110,7 +110,7 @@ const renderElements = () => {
110110
renderBanner();
111111
return false;
112112
}
113-
if (window.location.href.indexOf('bot.html') === -1) {
113+
if (window.location.pathname.indexOf('/bot') === -1) {
114114
render(<Logo />, document.getElementById('binary-logo'));
115115
render(<Footer />, document.getElementById('footer'));
116116
isEuCountry().then(isEu => showHideEuElements(isEu));
@@ -132,13 +132,13 @@ const renderElements = () => {
132132
const loginCheck = () => {
133133
if (endpoint()) return;
134134
moveToDeriv();
135-
if (window.location.href.indexOf('bot.html') === -1) {
135+
if (window.location.pathname.indexOf('/bot') === -1) {
136136
loadLang();
137137
}
138138
$('.show-on-load').show();
139139
if (bannerToken && window.location.pathname !== '/movetoderiv.html') {
140140
if (getTokenList().length) {
141-
if (!window.location.pathname.includes('/bot.html')) {
141+
if (!window.location.pathname.includes('/bot')) {
142142
window.location.pathname = `${window.location.pathname.replace(/\/+$/, '')}/bot.html`;
143143
}
144144
document.getElementById('bot-main').classList.remove('hidden');

src/indexPage/react-components/bot-landing/ModalComponent.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ const setDueDateAgain = () => {
1616

1717
const renderBanner = () => {
1818
const getqueryParameter = document.location.search;
19-
const getDefaultPath = window.location.href.replace('/bot.html', getqueryParameter);
19+
const getDefaultPath = window.location.href.replace(/\/bot(\.html)?/, getqueryParameter);
2020
window.location.replace(getDefaultPath);
2121
render(<ModalComponent />, document.getElementById('bot-landing-alert-popup'));
2222
render(<BotLanding />, document.getElementById('bot-landing'));
@@ -42,4 +42,4 @@ const ModalComponent = () => (
4242
</div>
4343
)
4444

45-
export default ModalComponent
45+
export default ModalComponent

0 commit comments

Comments
 (0)