1
0
mirror of https://codeberg.org/nobody/LocalCDN.git synced 2025-06-05 21:49:31 +02:00

Improved version selection

This commit is contained in:
nobody
2020-11-05 07:08:55 +01:00
parent 045751479a
commit 24dea685a3

View File

@@ -25,6 +25,7 @@
var shorthands = {}; var shorthands = {};
shorthands.specialFiles = function (channelHost, channelPath, searchString) { shorthands.specialFiles = function (channelHost, channelPath, searchString) {
let lastVersion;
/* /*
NOTE: NOTE:
jsDelivr allows to load several files in one request jsDelivr allows to load several files in one request
@@ -50,49 +51,55 @@ shorthands.specialFiles = function (channelHost, channelPath, searchString) {
'bundle': '' 'bundle': ''
}; };
} else if (Regex.GOOGLE_MATERIAL_ICONS.test(channelHost + channelPath + searchString)) { } else if (Regex.GOOGLE_MATERIAL_ICONS.test(channelHost + channelPath + searchString)) {
lastVersion = destinations.setLastVersion('/google-material-design-icons/');
return { return {
'source': channelHost, 'source': channelHost,
'versionDelivered': '3.0.1', 'versionDelivered': lastVersion,
'path': 'resources/google-material-design-icons/google-material-design-icons.css', 'path': 'resources/google-material-design-icons/google-material-design-icons.css',
'bundle': '' 'bundle': ''
}; };
} else if (Regex.BOOTSTRAP_DATEPICKER_3.test(channelPath)) { } else if (Regex.BOOTSTRAP_DATEPICKER_3.test(channelPath)) {
lastVersion = destinations.setLastVersion('/bootstrap-datepicker/1.');
return { return {
'source': channelHost, 'source': channelHost,
'versionDelivered': '1.9.0', 'versionDelivered': lastVersion,
'path': 'resources/bootstrap-datepicker/1.9.0/bootstrap-datepicker3.standalone.min.css', 'path': 'resources/bootstrap-datepicker/' + lastVersion + '/bootstrap-datepicker3.standalone.min.css',
'bundle': '' 'bundle': ''
}; };
} else if (Regex.BOOTSTRAP_DATEPICKER.test(channelPath)) { } else if (Regex.BOOTSTRAP_DATEPICKER.test(channelPath)) {
lastVersion = destinations.setLastVersion('/bootstrap-datepicker/1.');
return { return {
'source': channelHost, 'source': channelHost,
'versionDelivered': '1.9.0', 'versionDelivered': lastVersion,
'path': 'resources/bootstrap-datepicker/1.9.0/bootstrap-datepicker.standalone.min.css', 'path': 'resources/bootstrap-datepicker/' + lastVersion + '/bootstrap-datepicker.standalone.min.css',
'bundle': '' 'bundle': ''
}; };
} else if (Regex.FONT_AWESOME.test(channelHost + channelPath)) { } else if (Regex.FONT_AWESOME.test(channelHost + channelPath)) {
lastVersion = destinations.setLastVersion('/fontawesome/4.');
return { return {
'source': channelHost, 'source': channelHost,
'versionRequested': '4.6.3', 'versionRequested': '4.6.3',
'versionDelivered': '4.7.0', 'versionDelivered': lastVersion,
'path': 'resources/webfont/fa-loader.css', 'path': 'resources/webfont/fa-loader.css',
'bundle': '' 'bundle': ''
}; };
} else if (Regex.FONT_AWESOME_WITH_CODE.test(channelHost + channelPath)) { } else if (Regex.FONT_AWESOME_WITH_CODE.test(channelHost + channelPath)) {
let fileExtension = channelPath.endsWith('css') ? 'css' : 'jsm'; let fileExtension = channelPath.endsWith('css') ? 'css' : 'jsm';
lastVersion = destinations.setLastVersion('/fontawesome/4.');
return { return {
'source': channelHost, 'source': channelHost,
'versionRequested': '4.6.3', 'versionRequested': '4.6.3',
'versionDelivered': '4.7.0', 'versionDelivered': lastVersion,
'path': 'resources/webfont/fa-loader.' + fileExtension, 'path': 'resources/webfont/fa-loader.' + fileExtension,
'bundle': '' 'bundle': ''
}; };
} else if ((channelHost + channelPath) === 'cdn.jsdelivr.net/npm/vue') { } else if ((channelHost + channelPath) === 'cdn.jsdelivr.net/npm/vue') {
lastVersion = destinations.setLastVersion('/vue/2.');
return { return {
'source': channelHost, 'source': channelHost,
'versionRequested': 'latest', 'versionRequested': 'latest',
'versionDelivered': '2.6.12', 'versionDelivered': lastVersion,
'path': 'resources/vue/2.6.12/vue.min.jsm', 'path': 'resources/vue/' + lastVersion + '/vue.min.jsm',
'bundle': '' 'bundle': ''
}; };
} else if ((channelHost + channelPath) === 'ajax.cloudflare.com/cdn-cgi/scripts/7089c43e/cloudflare-static/rocket-loader.min.js') { } else if ((channelHost + channelPath) === 'ajax.cloudflare.com/cdn-cgi/scripts/7089c43e/cloudflare-static/rocket-loader.min.js') {
@@ -103,18 +110,21 @@ shorthands.specialFiles = function (channelHost, channelPath, searchString) {
'bundle': '' 'bundle': ''
}; };
} else if ((channelHost + channelPath) === 'unpkg.com/@umds/object-assign@4.1.1-beta.24/object-assign.min.js') { } else if ((channelHost + channelPath) === 'unpkg.com/@umds/object-assign@4.1.1-beta.24/object-assign.min.js') {
lastVersion = destinations.setLastVersion('/object-assign@4.');
return { return {
'source': channelHost, 'source': channelHost,
'versionRequested': '4.1.1', 'versionRequested': '4.1.1',
'path': 'resources/object-assign/4.1.1/object-assign.min.jsm', 'versionDelivered': lastVersion,
'path': 'resources/object-assign/' + lastVersion + '/object-assign.min.jsm',
'bundle': '' 'bundle': ''
}; };
} else if ((channelHost + channelPath) === 'netdna.bootstrapcdn.com/font-awesome/latest/css/font-awesome.min.css') { } else if ((channelHost + channelPath) === 'netdna.bootstrapcdn.com/font-awesome/latest/css/font-awesome.min.css') {
// This CDN delivers 'Font Awesome v4.7.0' as latest version // This CDN delivers 'Font Awesome v4.7.0' as latest version
lastVersion = destinations.setLastVersion('/fontawesome/4.');
return { return {
'source': channelHost, 'source': channelHost,
'versionRequested': '4.7.0', 'versionRequested': lastVersion,
'path': 'resources/fontawesome/4.7.0/css/font-awesome.min.css', 'path': 'resources/fontawesome/' + lastVersion + '/css/font-awesome.min.css',
'bundle': '' 'bundle': ''
}; };
} else if ((channelHost + channelPath) === 'cdnjs.cloudflare.com/ajax/libs/OwlCarousel2/2.0.0-beta.2.4/owl.carousel.min.js') { } else if ((channelHost + channelPath) === 'cdnjs.cloudflare.com/ajax/libs/OwlCarousel2/2.0.0-beta.2.4/owl.carousel.min.js') {
@@ -130,20 +140,14 @@ shorthands.specialFiles = function (channelHost, channelPath, searchString) {
if (file.endsWith('js')) { if (file.endsWith('js')) {
file = file + 'm'; file = file + 'm';
} }
lastVersion = destinations.setLastVersion('/select2/4.');
return { return {
'source': channelHost, 'source': channelHost,
'versionDelivered': '4.0.13', 'versionDelivered': lastVersion,
'versionRequested': '4.1.0-beta.1', 'versionRequested': '4.1.0-beta.1',
'path': 'resources/select2/4.0.13/' + helpers.extractFilenameFromPath(channelPath), 'path': 'resources/select2/' + lastVersion + '/' + helpers.extractFilenameFromPath(channelPath),
'bundle': 'Select2' 'bundle': 'Select2'
}; };
} else if ((channelHost + channelPath).startsWith('use.fontawesome.com/releases/v5.')) {
return {
'source': channelHost,
'versionDelivered': '5.15.1',
'path': 'resources/fontawesome/5.15.1/css/all.min.css',
'bundle': ''
};
} else { } else {
return false; return false;
} }