Files
formipay/node_modules/stylelint/lib/utils/getSchemeFromUrl.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

40 lines
939 B
JavaScript

'use strict';
const { URL } = require('url');
/**
* Get unit from value node
*
* Returns `null` if the unit is not found.
*
* @param {string} urlString
*/
module.exports = function getSchemeFromUrl(urlString) {
let protocol = null;
try {
protocol = new URL(urlString).protocol;
} catch {
return null;
}
if (protocol === null || typeof protocol === 'undefined') {
return null;
}
const scheme = protocol.slice(0, -1); // strip trailing `:`
// The URL spec does not require a scheme to be followed by `//`, but checking
// for it allows this rule to differentiate <scheme>:<hostname> urls from
// <hostname>:<port> urls. `data:` scheme urls are an exception to this rule.
const slashIndex = protocol.length;
const expectedSlashes = urlString.slice(slashIndex, slashIndex + 2);
const isSchemeLessUrl = expectedSlashes !== '//' && scheme !== 'data';
if (isSchemeLessUrl) {
return null;
}
return scheme;
};