diff --git a/src/loader/js/loader.js b/src/loader/js/loader.js index 3b9f2427965..be9ba6cc848 100644 --- a/src/loader/js/loader.js +++ b/src/loader/js/loader.js @@ -1006,12 +1006,18 @@ Y.Loader.prototype = { */ addGroup: function(o, name) { var mods = o.modules, - self = this, i, v; + self = this, + defaultBase = o.defaultBase || Y.config.defaultBase, + i, v; name = name || o.name; o.name = name; self.groups[name] = o; + if (!o.base && defaultBase && o.root) { + o.base = defaultBase + o.root; + } + if (o.patterns) { for (i in o.patterns) { if (o.patterns.hasOwnProperty(i)) { diff --git a/src/loader/tests/unit/assets/loader-tests.js b/src/loader/tests/unit/assets/loader-tests.js index 2a72215c2d9..161bc562d92 100644 --- a/src/loader/tests/unit/assets/loader-tests.js +++ b/src/loader/tests/unit/assets/loader-tests.js @@ -408,6 +408,79 @@ YUI.add('loader-tests', function(Y) { Assert.isTrue((out.js[0].indexOf('node-base-debug.js') > 0), 'node-base-debug was not found'); Assert.isTrue((out.js[0].indexOf('node-core-debug.js') === -1), 'node-core-debug was found'); }, + 'test defaultBase with groups': function() { + testY.applyConfig({ + defaultBase: 'http://mycdn.com/path/to/', + comboBase: 'http://mycdn.com/path/to/combo?', + root: 'yui-3.1.5.0/' + }); + var loader = new testY.Loader({ + groups: { + test1: { + root: 'zip/', + modules: { + foo: { + filter: 'min' + }, + bar: { + filter: 'min' + } + } + }, + test2: { + root: 'zap/', + modules: { + baz: { + filter: 'min' + } + } + + } + }, + require: ['foo', 'bar', 'baz'] + }); + var out = loader.resolve(true); + Assert.areSame(3, out.js.length, "Loader should not have combined URLs."); + Assert.areSame("http://mycdn.com/path/to/zip/foo/foo-min.js", out.js[0], "The url should be "); + Assert.areSame("http://mycdn.com/path/to/zip/bar/bar-min.js", out.js[1], "The url should be "); + Assert.areSame("http://mycdn.com/path/to/zap/baz/baz-min.js", out.js[2], "The url should be "); + }, + 'test base should take precedence over defaultBase': function() { + var loader = new testY.Loader({ + groups: { + test1: { + defaultBase: 'http://mycdn.com/path/to/', + base: 'http://basecdn.com/path/to/base/', + root: 'zip/', + modules: { + foo: { + filter: 'min' + }, + bar: { + filter: 'min' + } + } + }, + test2: { + defaultBase: 'http://mycdn.com/path/to/', + base: 'http://basecdn.com/path/to/base/', + root: 'zap/', + modules: { + baz: { + filter: 'min' + } + } + + } + }, + require: ['foo', 'bar', 'baz'] + }); + var out = loader.resolve(true); + Assert.areSame(3, out.js.length, "Loader should not have combined URLs."); + Assert.areSame("http://basecdn.com/path/to/base/foo/foo-min.js", out.js[0], "The url should be "); + Assert.areSame("http://basecdn.com/path/to/base/bar/bar-min.js", out.js[1], "The url should be "); + Assert.areSame("http://basecdn.com/path/to/base/baz/baz-min.js", out.js[2], "The url should be "); + }, test_group_filters: function() { var test = this; diff --git a/src/yui/js/yui.js b/src/yui/js/yui.js index c93f011b212..15764c63c96 100644 --- a/src/yui/js/yui.js +++ b/src/yui/js/yui.js @@ -349,7 +349,7 @@ proto = { mods: {}, // flat module map versions: {}, // version module map base: BASE, - cdn: BASE + VERSION + '/build/', + cdn: BASE + VERSION + '/', // bootstrapped: false, _idx: 0, _used: {}, @@ -496,7 +496,9 @@ proto = { Y.config.lang = Y.config.lang || 'en-US'; - Y.config.base = YUI.config.base || Y.Env.getBase(Y.Env._BASE_RE); + Y.config.base = YUI.config.base || + (YUI.config.defaultBase && YUI.config.root && YUI.config.defaultBase + YUI.config.root) || + Y.Env.getBase(Y.Env._BASE_RE); if (!filter || (!('mindebug').indexOf(filter))) { filter = 'min';