Bundle handling refactored
This commit is contained in:
parent
b4ba5b9f4e
commit
f1cc7736d7
|
@ -232,7 +232,27 @@ requestAnalyzer._findLocalTarget = function (resourceMappings, basePath, channel
|
||||||
|
|
||||||
requestAnalyzer._getPathOfBundle = function (initiator, channelHost, channelPath, targetPath, bundle) {
|
requestAnalyzer._getPathOfBundle = function (initiator, channelHost, channelPath, targetPath, bundle) {
|
||||||
let filename = channelPath.split('/').pop();
|
let filename = channelPath.split('/').pop();
|
||||||
|
|
||||||
if (bundle === 'MathJax (Bundle)' && filename !== 'MathJax.js') {
|
if (bundle === 'MathJax (Bundle)' && filename !== 'MathJax.js') {
|
||||||
|
filename = requestAnalyzer._handleMathJax(filename, channelPath, channelHost, initiator);
|
||||||
|
} else if (bundle === 'TinyMCE (Bundle)' && filename !== 'tinymce.min.js') {
|
||||||
|
filename = requestAnalyzer._handleTinyMCE(filename, channelPath, channelHost, initiator);
|
||||||
|
} else if (bundle === 'DataTables (Bundle)') {
|
||||||
|
filename = requestAnalyzer._handleDataTables(filename);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (filename === false) {
|
||||||
|
return {
|
||||||
|
'result': false,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
return helpers.formatFilename(filename.endsWith('.js')
|
||||||
|
? `${targetPath + filename}m`
|
||||||
|
: targetPath + filename);
|
||||||
|
};
|
||||||
|
|
||||||
|
requestAnalyzer._handleMathJax = function (filename, channelPath, channelHost, initiator) {
|
||||||
filename = channelPath.replace(Resource.MATHJAX, '');
|
filename = channelPath.replace(Resource.MATHJAX, '');
|
||||||
if (filename.startsWith('/npm/mathjax@3')) {
|
if (filename.startsWith('/npm/mathjax@3')) {
|
||||||
filename = filename.replace('/npm/mathjax@3/', '');
|
filename = filename.replace('/npm/mathjax@3/', '');
|
||||||
|
@ -243,29 +263,26 @@ requestAnalyzer._getPathOfBundle = function (initiator, channelHost, channelPath
|
||||||
if (!MathJaxFiles[filename] && !MathJax3Files[filename]) {
|
if (!MathJaxFiles[filename] && !MathJax3Files[filename]) {
|
||||||
console.warn(`${LogString.PREFIX} ${LogString.MISSING_RESOURCE} ${channelHost + channelPath}`);
|
console.warn(`${LogString.PREFIX} ${LogString.MISSING_RESOURCE} ${channelHost + channelPath}`);
|
||||||
log.append(initiator, channelHost + channelPath, '-', true);
|
log.append(initiator, channelHost + channelPath, '-', true);
|
||||||
return {
|
return false;
|
||||||
'result': false,
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
return filename;
|
||||||
|
};
|
||||||
|
|
||||||
|
requestAnalyzer._handleDataTables = function (filename) {
|
||||||
|
if (!filename.endsWith('.min.js') && filename.endsWith('.js')) {
|
||||||
|
return filename.replace('.js', '.min.js');
|
||||||
}
|
}
|
||||||
if (bundle === 'TinyMCE (Bundle)' && filename !== 'tinymce.min.js') {
|
return filename;
|
||||||
|
};
|
||||||
|
|
||||||
|
requestAnalyzer._handleTinyMCE = function (filename, channelPath, channelHost, initiator) {
|
||||||
filename = channelPath.replace(Resource.TINYMCE, '');
|
filename = channelPath.replace(Resource.TINYMCE, '');
|
||||||
if (filename.startsWith('plugins/')) {
|
if (filename.startsWith('plugins/')) {
|
||||||
console.warn(`${LogString.PREFIX} ${LogString.MISSING_RESOURCE} ${channelHost + channelPath}`);
|
console.warn(`${LogString.PREFIX} ${LogString.MISSING_RESOURCE} ${channelHost + channelPath}`);
|
||||||
log.append(initiator, channelHost + channelPath, '-', true);
|
log.append(initiator, channelHost + channelPath, '-', true);
|
||||||
return {
|
return false;
|
||||||
'result': false,
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
}
|
return filename;
|
||||||
if (bundle === 'DataTables (Bundle)') {
|
|
||||||
if (!filename.endsWith('.min.js') && filename.endsWith('.js')) {
|
|
||||||
filename = filename.replace('.js', '.min.js');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return helpers.formatFilename(filename.endsWith('.js')
|
|
||||||
? `${targetPath + filename}m`
|
|
||||||
: targetPath + filename);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
requestAnalyzer._applyAllowlistedDomains = function () {
|
requestAnalyzer._applyAllowlistedDomains = function () {
|
||||||
|
|
Loading…
Reference in New Issue