- function detectContextPath() {
- // eslint-disable-next-line max-len
- var SCRIPT_URL_REGEXP = /^(?:http|https):\/\/[^/]+(\/.*)\/(?:etc\.clientlibs|etc(\/.*)*\/clientlibs|libs(\/.*)*\/clientlibs|apps(\/.*)*\/clientlibs|etc\/designs).*\.js(\?.*)?$/;
- try {
- if (window.CQURLInfo) {
- contextPath = CQURLInfo.contextPath || "";
- } else {
- var scripts = document.getElementsByTagName("script");
- for (var i = 0; i < scripts.length; i++) {
- var result = SCRIPT_URL_REGEXP.exec(scripts[i].src);
- if (result) {
- contextPath = result[1];
- return;
- }
- }
- contextPath = "";
- }
- } catch (e) {
- // ignored
- }
- }
Raw Paste