diff --git a/lib/mappings.js b/lib/mappings.js index 86178c15bbb465beb51541723d4f273312a79f46..7ff31adf4917aef5ac336feefef85be5546e6609 100644 --- a/lib/mappings.js +++ b/lib/mappings.js @@ -41,7 +41,7 @@ var mappings = { 'swfobject/{version}/swfobject.': resources.swfobject, 'webfont/{version}/webfont.': resources.webfont, - // Common Shorthand Notations + // Common Shorthand Notations [Deprecated] 'dojo/1/dojo/dojo.': { path: 'resources/dojo/1.6.1/dojo/dojo.js.dec', type: 'application/javascript' @@ -122,7 +122,7 @@ var mappings = { 'ui/{version}/jquery-ui.js': resources.jQueryUI, 'ui/{version}/jquery-ui.min.js': resources.jQueryUI, - // Common Shorthand Notations + // Common Shorthand Notations [Deprecated] 'jquery-latest.': { path: 'resources/jquery/1.11.1/jquery.min.js.dec', type: 'application/javascript' @@ -130,6 +130,46 @@ var mappings = { 'jquery.': { path: 'resources/jquery/1.11.1/jquery.min.js.dec', type: 'application/javascript' + }, + 'jquery-1.3.min.js': { + path: 'resources/jquery/1.3.0/jquery.min.js.dec', + type: 'application/javascript' + }, + 'jquery-1.3.js': { + path: 'resources/jquery/1.3.0/jquery.min.js.dec', + type: 'application/javascript' + }, + 'jquery-1.4.min.js': { + path: 'resources/jquery/1.4.0/jquery.min.js.dec', + type: 'application/javascript' + }, + 'jquery-1.4.js': { + path: 'resources/jquery/1.4.0/jquery.min.js.dec', + type: 'application/javascript' + }, + 'jquery-1.5.min.js': { + path: 'resources/jquery/1.5.0/jquery.min.js.dec', + type: 'application/javascript' + }, + 'jquery-1.5.js': { + path: 'resources/jquery/1.5.0/jquery.min.js.dec', + type: 'application/javascript' + }, + 'jquery-1.6.min.js': { + path: 'resources/jquery/1.6.0/jquery.min.js.dec', + type: 'application/javascript' + }, + 'jquery-1.6.js': { + path: 'resources/jquery/1.6.0/jquery.min.js.dec', + type: 'application/javascript' + }, + 'jquery-1.7.min.js': { + path: 'resources/jquery/1.7.0/jquery.min.js.dec', + type: 'application/javascript' + }, + 'jquery-1.7.js': { + path: 'resources/jquery/1.7.0/jquery.min.js.dec', + type: 'application/javascript' } } }, diff --git a/lib/request-analyzer.js b/lib/request-analyzer.js index c0c11b78bd91e96a772e9a74766f7744672d4df4..30ce6aa98a7dfff87af8a0826fcd0483b4398c51 100644 --- a/lib/request-analyzer.js +++ b/lib/request-analyzer.js @@ -135,6 +135,17 @@ function _findLocalTarget(resourceMappings, basePath, channelPath) { versionNumber = resourcePath.match(VERSION_EXPRESSION); resourcePattern = resourcePath.replace(versionNumber, VERSION_PLACEHOLDER); + // Determine if the resource path has a static mapping. + if (resourceMappings[resourcePath]) { + + // Prepare and return a local target. + return { + path: resourceMappings[resourcePath].path, + type: resourceMappings[resourcePath].type + }; + } + + // Determine if the resource path fits into a resource mold. for (let resourceMold of Object.keys(resourceMappings)) { if (resourcePattern.startsWith(resourceMold)) { diff --git a/test/test-request-analyzer.js b/test/test-request-analyzer.js index c796334c7c652929fe17b51a46cd99da1046cac8..aaf9e465f75fe18f3b7fd703cd22d6ceaf757b02 100644 --- a/test/test-request-analyzer.js +++ b/test/test-request-analyzer.js @@ -281,6 +281,11 @@ exports['test jquery-ui on jquery cdn'] = function (assert) { assert.equal(target.path, localPaths.jQueryUI, 'Target was determined.'); }; +exports['test jquery shorthand on jquery cdn'] = function (assert) { + var target = requestAnalyzer.getLocalTarget('code.jquery.com', '/jquery-1.5.min.js'); + assert.equal(target.path, 'resources/jquery/1.5.0/jquery.min.js.dec', 'Target found for jquery shorthand on jquery cdn.'); +}; + // jsDelivr (MaxCDN) exports['test angular on jsdelivr'] = function (assert) {