Skip to content
This repository has been archived by the owner on Sep 11, 2023. It is now read-only.

Commit

Permalink
feat: adds support for ajax.aspnet.com
Browse files Browse the repository at this point in the history
  • Loading branch information
thisislawatts committed Apr 21, 2020
1 parent fb383b4 commit 241bc45
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/getImports/htmlParser.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
const htmlparser2 = require('htmlparser2');

const JQUERY = 'https://code.jquery.com/';
const ASPNETCDN = 'https://ajax.aspnetcdn.com/ajax/';

const MAXCDN = 'https://maxcdn.bootstrapcdn.com/';
const YANDEX = 'https://yastatic.net/';
const BOOTSTRAP = 'https://stackpath.bootstrapcdn.com/';
Expand All @@ -28,7 +30,8 @@ function packageFromUrl(url) {

if (isPathBased) {
let pkg = url.substring(isPathBased.length); // ?
const [name, version = 'latest'] = pkg.split('/');
const seperator = pkg.includes('/') ? '/' : '-';
const [name, version = 'latest'] = pkg.split(seperator);
return `${name}@${version}`; // ?
}

Expand All @@ -38,6 +41,12 @@ function packageFromUrl(url) {
return `${name}@${version.join('-')}`; // ?
}

if (url.toLowerCase().startsWith(ASPNETCDN)) {
let pkg = url.substring(ASPNETCDN.length); // ?
const [name, ...version] = pkg.split('-');
return `${name.split('/').pop()}@${version.join('-')}`; // ?
}

const isAtBased = atBased.find(_ => url.toLowerCase().startsWith(_));

if (isAtBased) {
Expand Down
6 changes: 6 additions & 0 deletions test/getImports/htmlParser.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ const testScenarios = [
package: 'jquery',
version: '3.3.1',
},
{
name: 'ASP net CDN',
url: 'https://ajax.aspnetcdn.com/ajax/jquery/jquery-3.2.1.min.js',
package: 'jquery',
version: '3.2.1',
},
{
name: 'Stackpath',
url:
Expand Down

0 comments on commit 241bc45

Please sign in to comment.