Improved: Handling of single version number (#129)

This commit is contained in:
nobody 2020-10-10 08:07:02 +02:00
parent 19ace23b45
commit 1ddaf28c31
No known key found for this signature in database
GPG Key ID: 8F6DE3D614FCFD7A
4 changed files with 10 additions and 10 deletions

View File

@ -56,6 +56,7 @@ const MessageResponse = {
const Resource = {
'MAPPING_EXPRESSION': /\.map$/i,
'VERSION_EXPRESSION': /(?:\d{1,2}\.){1,3}\d{1,2}/,
'SINGLE_NUMBER_EXPRESSION': /^\D+\d\D+$/,
'VERSION_PLACEHOLDER': '{version}'
};

View File

@ -117,8 +117,14 @@ requestAnalyzer._findLocalTarget = function (resourceMappings, basePath, channel
});
resourcePath = channelPath.replace(basePath, '');
versionNumber = resourcePath.match(Resource.VERSION_EXPRESSION);
resourcePattern = resourcePath.replace(versionNumber, Resource.VERSION_PLACEHOLDER);
if (Resource.SINGLE_NUMBER_EXPRESSION.test(channelPath)) {
versionNumber = channelPath.match(/\d/);
resourcePattern = resourcePath.replace(versionNumber, Resource.VERSION_PLACEHOLDER);
versionNumber = [versionNumber + '.0'];
} else {
versionNumber = resourcePath.match(Resource.VERSION_EXPRESSION);
resourcePattern = resourcePath.replace(versionNumber, Resource.VERSION_PLACEHOLDER);
}
shorthandResource = shorthands.specialFiles(channelHost, channelPath, destinationSearchString);
if (shorthandResource) {

View File

@ -108,14 +108,6 @@ shorthands.specialFiles = function (channelHost, channelPath, searchString) {
'path': 'resources/object-assign/4.1.1/object-assign.min.jsm',
'bundle': ''
};
} else if ((channelHost + channelPath).includes('cdn.jsdelivr.net/npm/algoliasearch@3/dist/algoliasearch.')) {
return {
'source': channelHost,
'versionRequested': '3.0',
'versionDelivered': '3.35.1',
'path': 'resources/algoliasearch/3.35.1/algoliasearch.min.jsm',
'bundle': ''
};
} else {
return false;
}

View File

@ -28,6 +28,7 @@
<li>Updated: Font Awesome v5.15.0 -> v5.15.1 (<a href="https://codeberg.org/nobody/LocalCDN/issues/125">#125</a>)</li>
<li>Fixed: Typo in Chart.js (<a href="https://codeberg.org/nobody/LocalCDN/issues/127">#127</a>)</li>
<li>Added: clipboard.js in cdn.jsdelivr.net (<a href="https://codeberg.org/nobody/LocalCDN/issues/128">#128</a>)</li>
<li>Improved: Handling of single version number (<a href="https://codeberg.org/nobody/LocalCDN/issues/129">#129</a>)</li>
</ul>
<div id="generator-section">
<div class="topic-label">