Files
formipay/node_modules/csp_evaluator/dist/utils.js
dwindown e8fbfb14c1 fix: prevent asset conflicts between React and Grid.js versions
Add coexistence checks to all enqueue methods to prevent loading
both React and Grid.js assets simultaneously.

Changes:
- ReactAdmin.php: Only enqueue React assets when ?react=1
- Init.php: Skip Grid.js when React active on admin pages
- Form.php, Coupon.php, Access.php: Restore classic assets when ?react=0
- Customer.php, Product.php, License.php: Add coexistence checks

Now the toggle between Classic and React versions works correctly.

Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
2026-04-18 17:02:14 +07:00

74 lines
2.5 KiB
JavaScript

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.applyCheckFunktionToDirectives = exports.matchWildcardUrls = exports.getHostname = exports.getSchemeFreeUrl = void 0;
function getSchemeFreeUrl(url) {
url = url.replace(/^\w[+\w.-]*:\/\//i, '');
url = url.replace(/^\/\//, '');
return url;
}
exports.getSchemeFreeUrl = getSchemeFreeUrl;
function getHostname(url) {
const hostname = new URL('https://' +
getSchemeFreeUrl(url)
.replace(':*', '')
.replace('*', 'wildcard_placeholder'))
.hostname.replace('wildcard_placeholder', '*');
const ipv6Regex = /^\[[\d:]+\]/;
if (getSchemeFreeUrl(url).match(ipv6Regex) && !hostname.match(ipv6Regex)) {
return '[' + hostname + ']';
}
return hostname;
}
exports.getHostname = getHostname;
function setScheme(u) {
if (u.startsWith('//')) {
return u.replace('//', 'https://');
}
return u;
}
function matchWildcardUrls(cspUrlString, listOfUrlStrings) {
const cspUrl = new URL(setScheme(cspUrlString
.replace(':*', '')
.replace('*', 'wildcard_placeholder')));
const listOfUrls = listOfUrlStrings.map(u => new URL(setScheme(u)));
const host = cspUrl.hostname.toLowerCase();
const hostHasWildcard = host.startsWith('wildcard_placeholder.');
const wildcardFreeHost = host.replace(/^\wildcard_placeholder/i, '');
const path = cspUrl.pathname;
const hasPath = path !== '/';
for (const url of listOfUrls) {
const domain = url.hostname;
if (!domain.endsWith(wildcardFreeHost)) {
continue;
}
if (!hostHasWildcard && host !== domain) {
continue;
}
if (hasPath) {
if (path.endsWith('/')) {
if (!url.pathname.startsWith(path)) {
continue;
}
}
else {
if (url.pathname !== path) {
continue;
}
}
}
return url;
}
return null;
}
exports.matchWildcardUrls = matchWildcardUrls;
function applyCheckFunktionToDirectives(parsedCsp, check) {
const directiveNames = Object.keys(parsedCsp.directives);
for (const directive of directiveNames) {
const directiveValues = parsedCsp.directives[directive];
if (directiveValues) {
check(directive, directiveValues);
}
}
}
exports.applyCheckFunktionToDirectives = applyCheckFunktionToDirectives;
//# sourceMappingURL=utils.js.map