1
0
mirror of https://codeberg.org/nobody/LocalCDN.git synced 2025-06-05 21:49:31 +02:00
This commit is contained in:
nobody42
2020-04-05 08:55:04 +02:00
parent f05a62266e
commit a8397ffa6b
4 changed files with 53 additions and 1 deletions

View File

@@ -99,6 +99,26 @@ requestAnalyzer._findLocalTarget = function (resourceMappings, basePath, channel
versionNumber = resourcePath.match(Resource.VERSION_EXPRESSION);
resourcePattern = resourcePath.replace(versionNumber, Resource.VERSION_PLACEHOLDER);
/*
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
*/
let regexJsDelivr = RegExp(/\/combine.*jquery.*hogan.*algoliasearch.*autocomplete.*/);
if (channelHost.includes('cdn.jsdelivr.net') && regexJsDelivr.test(channelPath)) {
return {
'source': channelHost,
'version': 'beta',
'path': 'resources/jsdelivr-combine-jquery-hogan-algoliasearch-autocomplete.jsm',
'bundle': ''
};
}
for (let resourceMold of Object.keys(resourceMappings)) {
if (resourcePattern.startsWith(resourceMold)) {