From 707d20a253dec0a2af1dc764d416920259aa4fec Mon Sep 17 00:00:00 2001 From: Matthew Wire Date: Tue, 10 May 2022 16:39:29 +0100 Subject: [PATCH] Allow AJAX paths to work properly with a custom basepage (as can be used on WordPress frontend) --- js/crm.ajax.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/js/crm.ajax.js b/js/crm.ajax.js index 39f7c85ef9..1a4983cc3a 100644 --- a/js/crm.ajax.js +++ b/js/crm.ajax.js @@ -28,11 +28,13 @@ path = path.split('#')[0]; } frag = path.split('?'); + // Remove basepage as it can be changed on some CMS eg. WordPress frontend. + frag[0] = frag[0].replace('civicrm/', '/'); // Encode url path only if slashes in placeholder were also encoded - if (tplURL[mode].indexOf('civicrm/placeholder-url-path') >= 0) { - url = tplURL[mode].replace('civicrm/placeholder-url-path', frag[0]); + if (tplURL[mode].indexOf('/placeholder-url-path') >= 0) { + url = tplURL[mode].replace('/placeholder-url-path', frag[0]); } else { - url = tplURL[mode].replace('civicrm%2Fplaceholder-url-path', encodeURIComponent(frag[0])); + url = tplURL[mode].replace('%2Fplaceholder-url-path', encodeURIComponent(frag[0])); } if (_.isEmpty(query)) { -- 2.25.1