Fix CRM.url to not encode hash on WP
authorColeman Watts <coleman@civicrm.org>
Thu, 5 Aug 2021 01:38:12 +0000 (21:38 -0400)
committerColeman Watts <coleman@civicrm.org>
Thu, 5 Aug 2021 03:10:00 +0000 (23:10 -0400)
js/crm.ajax.js

index 563e57a6dfbc5611af2c448b91c292faa6d3d165..609e1074a16dd56d345226eb6d63928325206d0b 100644 (file)
       mode = CRM.config && CRM.config.isFrontend ? 'front' : 'back';
     }
     query = query || '';
-    var url,
-      frag = path.split('?');
+    var url, frag, hash = '';
+    if (path.indexOf('#') > -1) {
+      hash = '#' + path.split('#')[1];
+      path = path.split('#')[0];
+    }
+    frag = path.split('?');
     // 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]);
@@ -39,7 +43,7 @@
     if (frag[1]) {
       url += (url.indexOf('?') < 0 ? '?' : '&') + frag[1];
     }
-    return url;
+    return url + hash;
   };
 
   $.fn.crmURL = function () {