diff --git a/lib/ace/config.js b/lib/ace/config.js index db36d59f..eb3de049 100644 --- a/lib/ace/config.js +++ b/lib/ace/config.js @@ -77,16 +77,26 @@ exports.moduleUrl = function(name, component) { var parts = name.split("/"); component = component || parts[parts.length - 2] || ""; - var base = parts[parts.length - 1].replace(component, "").replace(/(^[\-_])|([\-_]$)/, ""); + + // todo make this configurable or get rid of '-' + var sep = component == "snippets" ? "/" : "-"; + var base = parts[parts.length - 1]; + if (sep == "-") { + var re = new RegExp("^" + component + "[\-_]|[\-_]" + component + "$", "g"); + base = base.replace(re, ""); + } - if (!base && parts.length > 1) + if ((!base || base == component) && parts.length > 1) base = parts[parts.length - 2]; var path = options[component + "Path"]; - if (path == null) + if (path == null) { path = options.basePath; + } else if (sep == "/") { + component = sep = ""; + } if (path && path.slice(-1) != "/") path += "/"; - return path + component + "-" + base + this.get("suffix"); + return path + component + sep + base + this.get("suffix"); }; exports.setModuleUrl = function(name, subst) { diff --git a/lib/ace/config_test.js b/lib/ace/config_test.js index 0e4f5449..d09a2801 100644 --- a/lib/ace/config_test.js +++ b/lib/ace/config_test.js @@ -60,6 +60,16 @@ module.exports = { url = config.moduleUrl("foo/1", "theme"); assert.equal(url, "a/b1.js"); + url = config.moduleUrl("snippets/js"); + assert.equal(url, "a/b/snippets/js.js"); + + config.setModuleUrl("snippets/js", "_.js"); + url = config.moduleUrl("snippets/js"); + assert.equal(url, "_.js"); + + url = config.moduleUrl("ace/ext/textarea"); + assert.equal(url, "a/b/ext-textarea.js"); + assert.equal(); }, "test: define options" : function() {