Fixed #55
This commit is contained in:
parent
40f9a370ad
commit
e2b6197be8
|
@ -25,6 +25,10 @@ var files = {
|
|||
// AlgoliaSearch
|
||||
'resources/algoliasearch/3.35.1/algoliasearch.min.jsm': true,
|
||||
|
||||
// TEMPORARY SOLUTION
|
||||
// algoliasearch@3(algoliasearchLite.min.js),algoliasearch.helper@2
|
||||
'resources/algoliasearch3.33.0_algoliasearchLite_algoliasearchHelper.jsm': true,
|
||||
|
||||
// Angular Bootstrap
|
||||
'resources/angular-ui-bootstrap/1.3.3/ui-bootstrap-tpls.min.jsm': true,
|
||||
|
||||
|
|
|
@ -214,6 +214,10 @@ var mappings = {
|
|||
'underscorejs/{version}/underscore.': resources.underscore,
|
||||
'underscorejs/{version}/underscore-min.': resources.underscore,
|
||||
'webfontloader/{version}/webfont': resources.webfont
|
||||
},
|
||||
// TEMPORARY SOLUTION
|
||||
'/g/': {
|
||||
'algoliasearch@3(algoliasearchLite.min.js),algoliasearch.helper@2': resources.algoliasearchSearchlightHelper
|
||||
}
|
||||
},
|
||||
// Yandex CDN
|
||||
|
|
|
@ -89,7 +89,7 @@ requestAnalyzer._matchBasePath = function (hostMappings, channelPath) {
|
|||
|
||||
requestAnalyzer._findLocalTarget = function (resourceMappings, basePath, channelHost, channelPath) {
|
||||
|
||||
let resourcePath, versionNumber, resourcePattern, filename;
|
||||
let resourcePath, versionNumber, resourcePattern, filename, shorthandResource;
|
||||
|
||||
chrome.storage.local.get(Setting.LOGGING, function (items) {
|
||||
requestAnalyzer.logging = items.enableLogging;
|
||||
|
@ -99,26 +99,11 @@ 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': ''
|
||||
};
|
||||
shorthandResource = shorthands.specialFiles(channelHost, channelPath);
|
||||
if (shorthandResource) {
|
||||
return shorthandResource;
|
||||
}
|
||||
|
||||
|
||||
|
||||
for (let resourceMold of Object.keys(resourceMappings)) {
|
||||
|
||||
if (resourcePattern.startsWith(resourceMold)) {
|
||||
|
|
|
@ -24,6 +24,12 @@ var resources = {
|
|||
'path': 'resources/algoliasearch/3.35.1/algoliasearch.min.jsm',
|
||||
'type': 'application/javascript'
|
||||
},
|
||||
// TEMPORARY SOLUTION
|
||||
// algoliasearch@3(algoliasearchLite.min.js),algoliasearch.helper@2
|
||||
'algoliasearchSearchlightHelper': {
|
||||
'path': 'resources/algoliasearch3.33.0_algoliasearchLite_algoliasearchHelper.jsm',
|
||||
'type': 'application/javascript'
|
||||
},
|
||||
// AnguComplete
|
||||
'anguComplete': {
|
||||
'path': 'resources/angucomplete-alt/{version}/angucomplete-alt.min.jsm',
|
||||
|
|
|
@ -80,3 +80,33 @@ shorthands['sdn.geekzu.org'] = shorthands['ajax.googleapis.com'];
|
|||
|
||||
// USTC Linux User Group [Mirror]
|
||||
shorthands['ajax.proxy.ustclug.org'] = shorthands['ajax.googleapis.com'];
|
||||
|
||||
shorthands.specialFiles = function (channelHost, channelPath) {
|
||||
/*
|
||||
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': ''
|
||||
};
|
||||
} else if (channelHost.includes('cdn.jsdelivr.net') && channelPath.includes('algoliasearch@3(algoliasearchLite.min.js),algoliasearch.helper@2')) {
|
||||
// https://gitlab.com/nobody42/localcdn/-/issues/55
|
||||
return {
|
||||
'source': channelHost,
|
||||
'version': 'beta',
|
||||
'path': 'resources/algoliasearch3.33.0_algoliasearchLite_algoliasearchHelper.jsm',
|
||||
'bundle': ''
|
||||
};
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
|
|
@ -345,6 +345,8 @@ helpers.determineResourceName = function (filename) {
|
|||
return 'WOW';
|
||||
case 'jsdelivr-combine-jquery-hogan-algoliasearch-autocomplete.jsm':
|
||||
return 'jsDelivr combined';
|
||||
case 'algoliasearch3.33.0_algoliasearchLite_algoliasearchHelper.jsm':
|
||||
return 'jsDelivr combined';
|
||||
default:
|
||||
return 'Unknown';
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
New in LocalCDN:
|
||||
</div>
|
||||
<ul>
|
||||
<li></li>
|
||||
<li>Fixed <a href="https://gitlab.com/nobody42/localcdn/-/issues/55">#55</a></li>
|
||||
</ul>
|
||||
<div class="topic-label">
|
||||
Please update your uBlock/uMatrix rules
|
||||
|
|
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue