Code style
This commit is contained in:
parent
aa521e879e
commit
10c0887057
|
@ -141,13 +141,14 @@ manipulateDOM._removeCrossOriginAndIntegrityAttr = function (details) {
|
||||||
manipulateDOM._searchCharset = function (str, charset) {
|
manipulateDOM._searchCharset = function (str, charset) {
|
||||||
if (str.indexOf(`charset="${charset}"`) > 0) {
|
if (str.indexOf(`charset="${charset}"`) > 0) {
|
||||||
return str.replace(`charset="${charset}"`, 'charset="utf8"');
|
return str.replace(`charset="${charset}"`, 'charset="utf8"');
|
||||||
} else if (str.indexOf(`charset='${charset}'`) > 0) {
|
|
||||||
return str.replace(`charset='${charset}'`, 'charset=\'utf8\'');
|
|
||||||
} else if (str.indexOf(`charset=${charset}`) > 0) {
|
|
||||||
return str.replace(`charset=${charset}`, 'charset=utf8');
|
|
||||||
} else {
|
|
||||||
return str;
|
|
||||||
}
|
}
|
||||||
|
if (str.indexOf(`charset='${charset}'`) > 0) {
|
||||||
|
return str.replace(`charset='${charset}'`, 'charset=\'utf8\'');
|
||||||
|
}
|
||||||
|
if (str.indexOf(`charset=${charset}`) > 0) {
|
||||||
|
return str.replace(`charset=${charset}`, 'charset=utf8');
|
||||||
|
}
|
||||||
|
return str;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -106,7 +106,7 @@ requestAnalyzer.getLocalTarget = function (requestDetails, initiator) {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
basePath = requestAnalyzer._matchBasePath(hostMappings, destinationPath);
|
basePath = requestAnalyzer._matchBasePath(hostMappings, destinationPath)['result'];
|
||||||
resourceMappings = hostMappings[basePath];
|
resourceMappings = hostMappings[basePath];
|
||||||
|
|
||||||
if (!resourceMappings) {
|
if (!resourceMappings) {
|
||||||
|
@ -135,11 +135,15 @@ requestAnalyzer.getLocalTarget = function (requestDetails, initiator) {
|
||||||
requestAnalyzer._matchBasePath = function (hostMappings, channelPath) {
|
requestAnalyzer._matchBasePath = function (hostMappings, channelPath) {
|
||||||
for (let basePath of Object.keys(hostMappings)) {
|
for (let basePath of Object.keys(hostMappings)) {
|
||||||
if (channelPath.startsWith(basePath)) {
|
if (channelPath.startsWith(basePath)) {
|
||||||
return basePath;
|
return {
|
||||||
|
'result': basePath,
|
||||||
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return {
|
||||||
|
'result': false,
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
// eslint-disable-next-line max-len
|
// eslint-disable-next-line max-len
|
||||||
|
@ -165,7 +169,7 @@ requestAnalyzer._findLocalTarget = function (resourceMappings, basePath, channel
|
||||||
}
|
}
|
||||||
|
|
||||||
shorthandResource = shorthands.specialFiles(channelHost, channelPath, destinationSearchString);
|
shorthandResource = shorthands.specialFiles(channelHost, channelPath, destinationSearchString);
|
||||||
if (shorthandResource) {
|
if (shorthandResource['result'] !== false) {
|
||||||
if (requestAnalyzer.logging) {
|
if (requestAnalyzer.logging) {
|
||||||
console.log(`${LogString.PREFIX} ${LogString.REPLACED_RESOURCE} ${shorthandResource.path}`);
|
console.log(`${LogString.PREFIX} ${LogString.REPLACED_RESOURCE} ${shorthandResource.path}`);
|
||||||
log.append(initiator, channelHost + channelPath, shorthandResource.path, false);
|
log.append(initiator, channelHost + channelPath, shorthandResource.path, false);
|
||||||
|
@ -186,12 +190,12 @@ requestAnalyzer._findLocalTarget = function (resourceMappings, basePath, channel
|
||||||
targetPath = targetPath.replace(Resource.VERSION_PLACEHOLDER, versionNumber);
|
targetPath = targetPath.replace(Resource.VERSION_PLACEHOLDER, versionNumber);
|
||||||
// Replace the requested version with the latest depending on major version
|
// Replace the requested version with the latest depending on major version
|
||||||
versionDelivered = targets.setLastVersion(targetPath, versionNumber);
|
versionDelivered = targets.setLastVersion(targetPath, versionNumber);
|
||||||
if (versionDelivered === false) {
|
if (versionDelivered === '') {
|
||||||
return {
|
return {
|
||||||
'result': false,
|
'result': false,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
versionDelivered = versionDelivered.toString();
|
|
||||||
targetPath = targetPath.replace(versionNumber, versionDelivered);
|
targetPath = targetPath.replace(versionNumber, versionDelivered);
|
||||||
|
|
||||||
if (versionNumber === null) {
|
if (versionNumber === null) {
|
||||||
|
@ -206,7 +210,7 @@ requestAnalyzer._findLocalTarget = function (resourceMappings, basePath, channel
|
||||||
if (bundle !== '') {
|
if (bundle !== '') {
|
||||||
targetPath = requestAnalyzer._getPathOfBundle(initiator, channelHost, channelPath, targetPath, bundle);
|
targetPath = requestAnalyzer._getPathOfBundle(initiator, channelHost, channelPath, targetPath, bundle);
|
||||||
}
|
}
|
||||||
if (targetPath === false) {
|
if (targetPath['result'] === false) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -241,7 +245,9 @@ requestAnalyzer._getPathOfBundle = function (initiator, channelHost, channelPath
|
||||||
if (!MathJaxFiles[filename]) {
|
if (!MathJaxFiles[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 false;
|
return {
|
||||||
|
'result': false,
|
||||||
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return helpers.formatFilename(filename.endsWith('.js')
|
return helpers.formatFilename(filename.endsWith('.js')
|
||||||
|
|
|
@ -204,8 +204,10 @@ shorthands.specialFiles = function (channelHost, channelPath, searchString) {
|
||||||
} else if ((/cdn\.jsdelivr\.net\/npm\/vue@(2|3)/).test(CompleteURL)) {
|
} else if ((/cdn\.jsdelivr\.net\/npm\/vue@(2|3)/).test(CompleteURL)) {
|
||||||
let version = CompleteURL.match(Resource.VERSION_EXPRESSION);
|
let version = CompleteURL.match(Resource.VERSION_EXPRESSION);
|
||||||
lastVersion = targets.setLastVersion(`/vue/${version}.`);
|
lastVersion = targets.setLastVersion(`/vue/${version}.`);
|
||||||
if (lastVersion === false) {
|
if (lastVersion === '') {
|
||||||
return false;
|
return {
|
||||||
|
'result': false,
|
||||||
|
};
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
'source': channelHost,
|
'source': channelHost,
|
||||||
|
@ -232,7 +234,8 @@ shorthands.specialFiles = function (channelHost, channelPath, searchString) {
|
||||||
'path': 'resources/jquery/1.11.2/jquery.min.jsm',
|
'path': 'resources/jquery/1.11.2/jquery.min.jsm',
|
||||||
'bundle': ''
|
'bundle': ''
|
||||||
};
|
};
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
return {
|
||||||
|
'result': false,
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -95,16 +95,18 @@ statistics._filterAndSortData = function () {
|
||||||
|
|
||||||
statistics._mergeObjects = function (obj, arr) {
|
statistics._mergeObjects = function (obj, arr) {
|
||||||
for (let [key, value] of Object.entries(obj)) {
|
for (let [key, value] of Object.entries(obj)) {
|
||||||
let bundle = targets.determineBundle(key);
|
let domain, bundle;
|
||||||
|
domain = key;
|
||||||
|
bundle = targets.determineBundle(domain);
|
||||||
if (bundle !== '') {
|
if (bundle !== '') {
|
||||||
bundle = key.split('/');
|
bundle = domain.split('/');
|
||||||
key = `${bundle[0]}/${bundle[1]}/${bundle[2]}/`;
|
domain = `${bundle[0]}/${bundle[1]}/${bundle[2]}/`;
|
||||||
}
|
}
|
||||||
// If CDN/Framework exists, add it, otherwise create new one
|
// If CDN/Framework exists, add it, otherwise create new one
|
||||||
if (arr[key]) {
|
if (arr[domain]) {
|
||||||
arr[key] += value;
|
arr[domain] += value;
|
||||||
} else {
|
} else {
|
||||||
arr[key] = value;
|
arr[domain] = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue