2020-02-27 13:45:29 +01:00
|
|
|
/**
|
|
|
|
* Shorthands
|
2020-06-30 18:41:58 +02:00
|
|
|
* Belongs to LocalCDN (since 2020-02-26)
|
|
|
|
* (Origin: Decentraleyes)
|
2020-02-27 13:45:29 +01:00
|
|
|
*
|
|
|
|
* @author Thomas Rientjes
|
|
|
|
* @since 2018-02-24
|
2020-04-14 07:43:25 +02:00
|
|
|
*
|
2020-06-30 18:41:58 +02:00
|
|
|
* @author nobody
|
2020-04-14 07:43:25 +02:00
|
|
|
* @since 2020-02-26
|
|
|
|
*
|
2020-02-27 13:45:29 +01:00
|
|
|
* @license MPL 2.0
|
|
|
|
*
|
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
|
|
|
* You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
*/
|
|
|
|
|
|
|
|
'use strict';
|
|
|
|
|
2021-02-17 07:01:08 +01:00
|
|
|
|
2020-02-27 13:45:29 +01:00
|
|
|
/**
|
|
|
|
* Shorthands
|
|
|
|
*/
|
|
|
|
|
2020-08-23 07:35:37 +02:00
|
|
|
var shorthands = {};
|
2020-04-14 07:42:56 +02:00
|
|
|
|
2020-06-27 11:50:50 +02:00
|
|
|
shorthands.specialFiles = function (channelHost, channelPath, searchString) {
|
2021-02-17 07:01:08 +01:00
|
|
|
|
2020-11-05 07:08:55 +01:00
|
|
|
let lastVersion;
|
2021-04-16 06:37:48 +02:00
|
|
|
const CompleteURL = channelHost + channelPath + searchString;
|
2020-04-14 07:42:56 +02:00
|
|
|
|
2021-02-17 07:01:08 +01:00
|
|
|
/**
|
|
|
|
* NOTE:
|
|
|
|
* jsDelivr allows to load several files in one request
|
|
|
|
* This is just a workaround. If there are more websites which use this,
|
|
|
|
* we will have to do crazy things here to find and redirect these files.
|
|
|
|
*
|
|
|
|
* It's not possible to respond to a request with multiple redirections
|
|
|
|
* https://gitlab.com/nobody42/localcdn/-/issues/45
|
|
|
|
*/
|
2020-08-23 07:30:58 +02:00
|
|
|
|
|
|
|
if (Regex.JSDELIVR_COMBINE.test(channelHost + channelPath)) {
|
2020-04-14 07:42:56 +02:00
|
|
|
return {
|
|
|
|
'source': channelHost,
|
2020-08-23 07:35:37 +02:00
|
|
|
'versionDelivered': 'beta',
|
2020-04-14 07:42:56 +02:00
|
|
|
'path': 'resources/jsdelivr-combine-jquery-hogan-algoliasearch-autocomplete.jsm',
|
|
|
|
'bundle': ''
|
|
|
|
};
|
2020-08-23 07:30:58 +02:00
|
|
|
} else if ((channelHost + channelPath) === 'cdn.jsdelivr.net/g/algoliasearch@3(algoliasearchLite.min.js),algoliasearch.helper@2') {
|
2020-04-14 07:42:56 +02:00
|
|
|
// https://gitlab.com/nobody42/localcdn/-/issues/55
|
|
|
|
return {
|
|
|
|
'source': channelHost,
|
2020-08-23 07:35:37 +02:00
|
|
|
'versionDelivered': 'beta',
|
2020-04-14 07:42:56 +02:00
|
|
|
'path': 'resources/algoliasearch3.33.0_algoliasearchLite_algoliasearchHelper.jsm',
|
|
|
|
'bundle': ''
|
|
|
|
};
|
2021-04-16 06:37:48 +02:00
|
|
|
} else if (Regex.GOOGLE_MATERIAL_ICONS.test(CompleteURL)) {
|
2020-11-05 13:44:41 +01:00
|
|
|
lastVersion = targets.setLastVersion('/google-material-design-icons/');
|
2020-06-27 11:50:50 +02:00
|
|
|
return {
|
|
|
|
'source': channelHost,
|
2020-11-05 07:08:55 +01:00
|
|
|
'versionDelivered': lastVersion,
|
2020-06-27 11:50:50 +02:00
|
|
|
'path': 'resources/google-material-design-icons/google-material-design-icons.css',
|
|
|
|
'bundle': ''
|
|
|
|
};
|
2021-04-16 06:37:48 +02:00
|
|
|
} else if (channelPath.endsWith(MaterialIcons.DEFAULT)) {
|
|
|
|
lastVersion = targets.setLastVersion('/google-material-design-icons/');
|
|
|
|
return {
|
|
|
|
'source': channelHost,
|
|
|
|
'versionDelivered': lastVersion,
|
|
|
|
'path': `resources/google-material-design-icons/${lastVersion}/MaterialIcons.woff2`,
|
|
|
|
'bundle': ''
|
|
|
|
};
|
2020-08-23 07:30:58 +02:00
|
|
|
} else if (Regex.BOOTSTRAP_DATEPICKER_3.test(channelPath)) {
|
2020-11-05 13:44:41 +01:00
|
|
|
lastVersion = targets.setLastVersion('/bootstrap-datepicker/1.');
|
2020-07-13 18:50:13 +02:00
|
|
|
return {
|
|
|
|
'source': channelHost,
|
2020-11-05 07:08:55 +01:00
|
|
|
'versionDelivered': lastVersion,
|
2021-02-17 07:01:08 +01:00
|
|
|
'path': `resources/bootstrap-datepicker/${lastVersion}/bootstrap-datepicker3.standalone.min.css`,
|
2020-07-13 18:50:13 +02:00
|
|
|
'bundle': ''
|
|
|
|
};
|
2020-08-23 07:30:58 +02:00
|
|
|
} else if (Regex.BOOTSTRAP_DATEPICKER.test(channelPath)) {
|
2020-11-05 13:44:41 +01:00
|
|
|
lastVersion = targets.setLastVersion('/bootstrap-datepicker/1.');
|
2020-07-13 18:50:13 +02:00
|
|
|
return {
|
|
|
|
'source': channelHost,
|
2020-11-05 07:08:55 +01:00
|
|
|
'versionDelivered': lastVersion,
|
2021-02-17 07:01:08 +01:00
|
|
|
'path': `resources/bootstrap-datepicker/${lastVersion}/bootstrap-datepicker.standalone.min.css`,
|
2020-07-13 18:50:13 +02:00
|
|
|
'bundle': ''
|
|
|
|
};
|
2020-08-23 07:30:58 +02:00
|
|
|
} else if (Regex.FONT_AWESOME.test(channelHost + channelPath)) {
|
2021-02-02 05:48:41 +01:00
|
|
|
lastVersion = targets.setLastVersion('/font-awesome/4.');
|
2020-08-03 13:36:13 +02:00
|
|
|
return {
|
|
|
|
'source': channelHost,
|
|
|
|
'versionRequested': '4.6.3',
|
2020-11-05 07:08:55 +01:00
|
|
|
'versionDelivered': lastVersion,
|
2020-08-19 10:00:26 +02:00
|
|
|
'path': 'resources/webfont/fa-loader.css',
|
2020-08-03 13:36:13 +02:00
|
|
|
'bundle': ''
|
|
|
|
};
|
2020-08-23 07:30:58 +02:00
|
|
|
} else if (Regex.FONT_AWESOME_WITH_CODE.test(channelHost + channelPath)) {
|
2020-10-18 07:30:00 +02:00
|
|
|
let fileExtension = channelPath.endsWith('css') ? 'css' : 'jsm';
|
2021-02-02 05:48:41 +01:00
|
|
|
lastVersion = targets.setLastVersion('/font-awesome/4.');
|
2020-08-03 13:36:13 +02:00
|
|
|
return {
|
|
|
|
'source': channelHost,
|
|
|
|
'versionRequested': '4.6.3',
|
2020-11-05 07:08:55 +01:00
|
|
|
'versionDelivered': lastVersion,
|
2021-02-17 07:01:08 +01:00
|
|
|
'path': `resources/webfont/fa-loader.${fileExtension}`,
|
2020-08-03 13:36:13 +02:00
|
|
|
'bundle': ''
|
|
|
|
};
|
2020-08-23 07:36:41 +02:00
|
|
|
} else if ((channelHost + channelPath) === 'cdn.jsdelivr.net/npm/vue') {
|
2020-11-05 13:44:41 +01:00
|
|
|
lastVersion = targets.setLastVersion('/vue/2.');
|
2020-08-23 07:36:41 +02:00
|
|
|
return {
|
|
|
|
'source': channelHost,
|
|
|
|
'versionRequested': 'latest',
|
2020-11-05 07:08:55 +01:00
|
|
|
'versionDelivered': lastVersion,
|
2021-02-17 07:01:08 +01:00
|
|
|
'path': `resources/vue/${lastVersion}/vue.min.jsm`,
|
2020-08-23 07:36:41 +02:00
|
|
|
'bundle': ''
|
|
|
|
};
|
2021-04-29 07:18:12 +02:00
|
|
|
} else if (Regex.ROCKET_LOADER.test(CompleteURL)) {
|
2020-08-30 22:20:31 +02:00
|
|
|
return {
|
|
|
|
'source': channelHost,
|
|
|
|
'versionRequested': 'latest',
|
|
|
|
'path': 'resources/rocket-loader/latest/rocket-loader.min.jsm',
|
|
|
|
'bundle': ''
|
|
|
|
};
|
2020-09-20 08:22:37 +02:00
|
|
|
} else if ((channelHost + channelPath) === 'unpkg.com/@umds/object-assign@4.1.1-beta.24/object-assign.min.js') {
|
2020-11-05 13:44:41 +01:00
|
|
|
lastVersion = targets.setLastVersion('/object-assign@4.');
|
2020-09-20 08:22:37 +02:00
|
|
|
return {
|
|
|
|
'source': channelHost,
|
|
|
|
'versionRequested': '4.1.1',
|
2020-11-05 07:08:55 +01:00
|
|
|
'versionDelivered': lastVersion,
|
2021-02-17 07:01:08 +01:00
|
|
|
'path': `resources/object-assign/${lastVersion}/object-assign.min.jsm`,
|
2020-09-20 08:22:37 +02:00
|
|
|
'bundle': ''
|
|
|
|
};
|
2020-10-11 08:10:37 +02:00
|
|
|
} 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
|
2021-02-02 05:48:41 +01:00
|
|
|
lastVersion = targets.setLastVersion('/font-awesome/4.');
|
2020-10-11 08:10:37 +02:00
|
|
|
return {
|
|
|
|
'source': channelHost,
|
2020-11-05 07:08:55 +01:00
|
|
|
'versionRequested': lastVersion,
|
2021-02-17 07:01:08 +01:00
|
|
|
'path': `resources/font-awesome/${lastVersion}/css/font-awesome.min.css`,
|
2020-10-11 08:10:37 +02:00
|
|
|
'bundle': ''
|
|
|
|
};
|
2020-10-25 18:27:07 +01:00
|
|
|
} else if ((channelHost + channelPath).startsWith('cdn.jsdelivr.net/npm/select2@4.1.0-beta.1/')) {
|
2020-11-15 12:33:44 +01:00
|
|
|
if (channelPath.endsWith('js')) {
|
|
|
|
channelPath += 'm';
|
2020-10-25 18:27:07 +01:00
|
|
|
}
|
2020-11-05 13:44:41 +01:00
|
|
|
lastVersion = targets.setLastVersion('/select2/4.');
|
2020-10-25 18:27:07 +01:00
|
|
|
return {
|
|
|
|
'source': channelHost,
|
2020-11-05 07:08:55 +01:00
|
|
|
'versionDelivered': lastVersion,
|
2020-10-25 18:27:07 +01:00
|
|
|
'versionRequested': '4.1.0-beta.1',
|
2021-02-17 07:01:08 +01:00
|
|
|
'path': `resources/select2/${lastVersion}/${helpers.extractFilenameFromPath(channelPath)}`,
|
2020-10-25 18:27:07 +01:00
|
|
|
'bundle': 'Select2'
|
|
|
|
};
|
2020-11-08 20:08:58 +01:00
|
|
|
} else if (channelHost + channelPath === 'cdn.jsdelivr.net/npm/anchor-js/anchor.min.js') {
|
|
|
|
// This CDN always delivers the latest version of 'AnchorJS'
|
|
|
|
lastVersion = targets.setLastVersion('/anchor-js/4.');
|
|
|
|
return {
|
|
|
|
'source': channelHost,
|
|
|
|
'versionDelivered': lastVersion,
|
|
|
|
'versionRequested': lastVersion,
|
2021-02-17 07:01:08 +01:00
|
|
|
'path': `resources/anchor-js/${lastVersion}/anchor.min.jsm`,
|
2020-11-08 20:08:58 +01:00
|
|
|
'bundle': ''
|
|
|
|
};
|
2020-11-20 08:57:44 +01:00
|
|
|
} else if (Regex.BOOTSTRAP_FONTS_ONLY.test(channelPath)) {
|
|
|
|
return {
|
|
|
|
'source': channelHost,
|
2021-02-17 07:01:08 +01:00
|
|
|
'path': `resources/twitter-bootstrap/fonts/${helpers.extractFilenameFromPath(channelPath)}`,
|
2020-11-20 08:57:44 +01:00
|
|
|
'bundle': 'Bootstrap (Fonts)'
|
|
|
|
};
|
2021-04-30 07:14:04 +02:00
|
|
|
} else if (CompleteURL === 'cdn.jsdelivr.net/npm/videojs-seek-buttons/dist/videojs-seek-buttons.min.js') {
|
|
|
|
lastVersion = targets.setLastVersion('/videojs-seek-buttons/');
|
|
|
|
return {
|
|
|
|
'source': channelHost,
|
|
|
|
'versionDelivered': lastVersion,
|
|
|
|
'versionRequested': lastVersion,
|
|
|
|
'path': `resources/videojs-seek-buttons/${lastVersion}/videojs-seek-buttons.min.jsm`,
|
|
|
|
'bundle': 'videojs-seek-buttons'
|
|
|
|
};
|
2021-05-13 07:11:03 +02:00
|
|
|
} else if ((channelHost + channelPath).startsWith('cdn.jsdelivr.net/gh/johnroy-ui/up@master/materialize.')) {
|
|
|
|
if (channelPath.endsWith('js')) {
|
|
|
|
channelPath = 'js/materialize.min.js';
|
|
|
|
} else {
|
|
|
|
channelPath = 'css/materialize.min.css';
|
|
|
|
}
|
|
|
|
return {
|
|
|
|
'source': channelHost,
|
|
|
|
'versionDelivered': '1.0.0',
|
|
|
|
'versionRequested': '1.0.0',
|
|
|
|
'path': `resources/materialize/1.0.0/${channelPath}`,
|
|
|
|
'bundle': 'Materialize'
|
|
|
|
};
|
2021-12-28 08:09:11 +01:00
|
|
|
} else if (CompleteURL === 'cdn.jsdelivr.net/npm/vue@2') {
|
|
|
|
lastVersion = targets.setLastVersion('/vue/2.');
|
|
|
|
if (lastVersion === '') {
|
|
|
|
return {
|
|
|
|
'result': false,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
return {
|
|
|
|
'source': channelHost,
|
|
|
|
'versionDelivered': lastVersion,
|
|
|
|
'versionRequested': lastVersion,
|
|
|
|
'path': `resources/vue/${lastVersion}/vue.min.jsm`,
|
|
|
|
'bundle': ''
|
|
|
|
};
|
|
|
|
} else if (CompleteURL === 'cdn.jsdelivr.net/npm/vue@3') {
|
|
|
|
lastVersion = targets.setLastVersion('/vue/3.');
|
2021-12-05 07:30:31 +01:00
|
|
|
if (lastVersion === '') {
|
|
|
|
return {
|
|
|
|
'result': false,
|
|
|
|
};
|
2021-07-27 06:16:27 +02:00
|
|
|
}
|
2021-07-19 05:53:14 +02:00
|
|
|
return {
|
|
|
|
'source': channelHost,
|
|
|
|
'versionDelivered': lastVersion,
|
|
|
|
'versionRequested': lastVersion,
|
|
|
|
'path': `resources/vue/${lastVersion}/vue.min.jsm`,
|
|
|
|
'bundle': ''
|
|
|
|
};
|
2021-07-30 21:00:21 +02:00
|
|
|
} else if (CompleteURL.startsWith('cdn.jsdelivr.net/npm/exif-js')) {
|
|
|
|
lastVersion = targets.setLastVersion('/exif-js/2.');
|
|
|
|
return {
|
|
|
|
'source': channelHost,
|
|
|
|
'versionDelivered': lastVersion,
|
|
|
|
'versionRequested': lastVersion,
|
|
|
|
'path': `resources/exif-js/${lastVersion}/exif.min.jsm`,
|
|
|
|
'bundle': ''
|
|
|
|
};
|
2021-11-10 06:10:53 +01:00
|
|
|
} else if (CompleteURL.startsWith('ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js') ||
|
|
|
|
CompleteURL.startsWith('code.jquery.com/jquery-latest.')) {
|
2021-08-15 18:24:59 +02:00
|
|
|
return {
|
|
|
|
'source': channelHost,
|
|
|
|
'versionDelivered': '1.11.2',
|
|
|
|
'versionRequested': '1.11.1',
|
|
|
|
'path': 'resources/jquery/1.11.2/jquery.min.jsm',
|
|
|
|
'bundle': ''
|
|
|
|
};
|
2022-04-18 06:32:17 +02:00
|
|
|
} else if (CompleteURL.startsWith('code.createjs.com/createjs-')) {
|
|
|
|
lastVersion = targets.setLastVersion('/createjs/');
|
|
|
|
return {
|
|
|
|
'source': channelHost,
|
|
|
|
'versionDelivered': lastVersion,
|
|
|
|
'versionRequested': lastVersion,
|
|
|
|
'path': `resources/createjs/${lastVersion}/createjs.min.jsm`,
|
|
|
|
'bundle': ''
|
|
|
|
};
|
2022-09-30 06:22:42 +02:00
|
|
|
} else if (CompleteURL.startsWith('cdnjs.cloudflare.com/ajax/libs/gsap/latest/')) {
|
|
|
|
if (channelPath.endsWith('js')) {
|
|
|
|
channelPath += 'm';
|
|
|
|
}
|
|
|
|
lastVersion = '1.20.5';
|
|
|
|
return {
|
|
|
|
'source': channelHost,
|
|
|
|
'versionDelivered': lastVersion,
|
|
|
|
'path': `resources/gsap/${lastVersion}/${helpers.extractFilenameFromPath(channelPath)}`,
|
|
|
|
'bundle': 'GSAP'
|
|
|
|
};
|
2022-10-11 07:03:26 +02:00
|
|
|
} else if (CompleteURL.startsWith('cdn.jsdelivr.net/npm/@mdi/font@latest/css/materialdesignicons.')) {
|
|
|
|
return {
|
|
|
|
'source': channelHost,
|
|
|
|
'versionDelivered': 'latest',
|
|
|
|
'versionRequested': 'latest',
|
|
|
|
'path': 'resources/google-material-design-icons/google-material-design-icons.css',
|
|
|
|
'bundle': ''
|
|
|
|
};
|
2022-10-24 18:36:34 +02:00
|
|
|
} else if (CompleteURL.startsWith('cdn.jsdelivr.net/npm/@webcomponents/webcomponentsjs/webcomponents-loader.')) {
|
|
|
|
lastVersion = targets.setLastVersion('/webcomponentsjs/');
|
|
|
|
return {
|
|
|
|
'source': channelHost,
|
|
|
|
'versionDelivered': lastVersion,
|
|
|
|
'versionRequested': 'latest',
|
|
|
|
'path': `resources/webcomponentsjs/${lastVersion}/webcomponents-loader.min.jsm`,
|
|
|
|
'bundle': ''
|
|
|
|
};
|
2020-04-14 07:42:56 +02:00
|
|
|
}
|
2021-12-05 07:30:31 +01:00
|
|
|
return {
|
|
|
|
'result': false,
|
|
|
|
};
|
2020-04-14 07:42:56 +02:00
|
|
|
};
|