Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions src/loadrunner.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -515,6 +516,7 @@
context.define = amdDefine;

using.path = '';
using.loadRunnerFileRegex = loadRunnerFileRegex;

using.matchers = [];
using.matchers.add = function(regex, factory) {
Expand Down Expand Up @@ -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() {});
Expand Down
8 changes: 7 additions & 1 deletion test/test.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,13 @@ <h2 id="qunit-userAgent"></h2>
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() {
Expand Down Expand Up @@ -391,7 +398,6 @@ <h2 id="qunit-userAgent"></h2>
});



}
</script>

Expand Down