From c27beb0afb6729eea7f0d7163546bdc9b0a5e4da Mon Sep 17 00:00:00 2001 From: Matt Sanford Date: Thu, 30 Jun 2011 11:39:20 -0700 Subject: [PATCH] =?UTF-8?q?Add=20support=20for=20versioned=20loadrunner.js?= =?UTF-8?q?=20files.=20Versions=20are=20Pro=20Style=E2=84=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/loadrunner.js | 8 +++++--- test/test.html | 8 +++++++- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/loadrunner.js b/src/loadrunner.js index 9185b4f..a3e61a7 100644 --- a/src/loadrunner.js +++ b/src/loadrunner.js @@ -5,10 +5,11 @@ scriptsInProgress = {}, modulesInProgress = {}, loadedModule, currentScript, activeScripts = {}, oldUsing = context.using, oldProvide = context.provide, oldDefine = context.define, - oldLoadrunner = context.loadrunner; + oldLoadrunner = context.loadrunner, + loadRunnerFileRegex = /loadrunner([v0-9\.-]+)?\.js(\?|#|$)/; for (var i=0, s; s = scripts[i]; i++) { - if (s.src.match(/loadrunner\.js(\?|#|$)/)) { + if (s.src.match(loadRunnerFileRegex)) { scriptTag = s; break; } @@ -515,6 +516,7 @@ context.define = amdDefine; using.path = ''; + using.loadRunnerFileRegex = loadRunnerFileRegex; using.matchers = []; using.matchers.add = function(regex, factory) { @@ -544,7 +546,7 @@ } if (scriptTag) { - using.path = scriptTag.getAttribute('data-path') || scriptTag.src.split(/loadrunner\.js/)[0] || ''; + using.path = scriptTag.getAttribute('data-path') || scriptTag.src.split(loadRunnerFileRegex)[0] || ''; if (main = scriptTag.getAttribute('data-main')) { using.apply(context, main.split(/\s*,\s*/)).then(function() {}); diff --git a/test/test.html b/test/test.html index 7648cb3..7075075 100644 --- a/test/test.html +++ b/test/test.html @@ -26,6 +26,13 @@

ok(mainLoaded, 'main should be loaded'); }); + QUnit.test('should be able to version the loadrunner.js file', function() { + ok('loadrunner.js'.match(using.loadRunnerFileRegex), 'unversioned allowed'); + ok('loadrunner-20110630.js'.match(using.loadRunnerFileRegex), 'dated version allowed'); + ok('loadrunner-1.0.0.js'.match(using.loadRunnerFileRegex), 'numeric version allowed'); + ok('loadrunner-v1.0.0.js'.match(using.loadRunnerFileRegex), 'numeric version with v allowed'); + }); + QUnit.module('module'); QUnit.test('should be able to define a module with an object literal', function() { @@ -391,7 +398,6 @@

}); - }