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>
39 lines
1.1 KiB
JavaScript
39 lines
1.1 KiB
JavaScript
"use strict";
|
|
|
|
/**
|
|
* @param {string[]} pathComponents path components
|
|
* @returns {string} normalized url
|
|
*/
|
|
function normalizeUrlInner(pathComponents) {
|
|
return pathComponents.reduce(function (accumulator, item) {
|
|
switch (item) {
|
|
case "..":
|
|
accumulator.pop();
|
|
break;
|
|
case ".":
|
|
break;
|
|
default:
|
|
accumulator.push(item);
|
|
}
|
|
return accumulator;
|
|
}, /** @type {string[]} */[]).join("/");
|
|
}
|
|
|
|
/**
|
|
* @param {string} urlString url string
|
|
* @returns {string} normalized url string
|
|
*/
|
|
module.exports = function normalizeUrl(urlString) {
|
|
urlString = urlString.trim();
|
|
if (/^data:/i.test(urlString)) {
|
|
return urlString;
|
|
}
|
|
var protocol =
|
|
// eslint-disable-next-line unicorn/prefer-includes
|
|
urlString.indexOf("//") !== -1 ? "".concat(urlString.split("//")[0], "//") : "";
|
|
var components = urlString.replace(new RegExp(protocol, "i"), "").split("/");
|
|
var host = components[0].toLowerCase().replace(/\.$/, "");
|
|
components[0] = "";
|
|
var path = normalizeUrlInner(components);
|
|
return protocol + host + path;
|
|
}; |