mirror of
https://github.com/systemjs/systemjs.git
synced 2026-01-25 14:57:38 +00:00
fix map configuration double slashing bug
This commit is contained in:
parent
c9cccd18d4
commit
720aa9e4e5
@ -149,12 +149,17 @@ export function setConfig (cfg, isEnvConfig) {
|
||||
var v = cfg.map[p];
|
||||
|
||||
if (typeof v === 'string') {
|
||||
config.map[p] = coreResolve.call(loader, config, v, undefined, false, false);
|
||||
var mapped = coreResolve.call(loader, config, v, undefined, false, false);
|
||||
if (mapped[mapped.length -1] === '/' && p[p.length - 1] !== ':' && p[p.length - 1] !== '/')
|
||||
mapped = mapped.substr(0, mapped.length - 1);
|
||||
config.map[p] = mapped;
|
||||
}
|
||||
|
||||
// object map
|
||||
else {
|
||||
var pkgName = coreResolve.call(loader, config, p, undefined, true, true);
|
||||
var pkgName = coreResolve.call(loader, config, p[p.length - 1] !== '/' ? p + '/' : p, undefined, true, true);
|
||||
pkgName = pkgName.substr(0, pkgName.length - 1);
|
||||
|
||||
var pkg = config.packages[pkgName];
|
||||
if (!pkg) {
|
||||
pkg = config.packages[pkgName] = createPackage();
|
||||
@ -191,7 +196,7 @@ export function setConfig (cfg, isEnvConfig) {
|
||||
if (p.match(/^([^\/]+:)?\/\/$/))
|
||||
throw new TypeError('"' + p + '" is not a valid package name.');
|
||||
|
||||
var pkgName = coreResolve.call(loader, config, p[p.length -1] !== '/' ? p + '/' : p, undefined, true, true);
|
||||
var pkgName = coreResolve.call(loader, config, p[p.length - 1] !== '/' ? p + '/' : p, undefined, true, true);
|
||||
pkgName = pkgName.substr(0, pkgName.length - 1);
|
||||
|
||||
setPkgConfig(config.packages[pkgName] = config.packages[pkgName] || createPackage(), cfg.packages[p], pkgName, false, config);
|
||||
|
||||
30
test/test.js
30
test/test.js
@ -316,6 +316,23 @@ suite('SystemJS Standard Tests', function() {
|
||||
});
|
||||
});
|
||||
|
||||
test('Relative map and package config', function () {
|
||||
System.config({
|
||||
map: {
|
||||
helloworld: './'
|
||||
},
|
||||
packages: {
|
||||
helloworld: {
|
||||
main: './helloworld.js'
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return System.normalize('helloworld').then(function (normalized) {
|
||||
ok(normalized.substr(normalized.length - 18, 18) === 'test/helloworld.js');
|
||||
});
|
||||
});
|
||||
|
||||
test('Package with json loader', function () {
|
||||
System.config({
|
||||
paths: {
|
||||
@ -419,6 +436,17 @@ suite('SystemJS Standard Tests', function() {
|
||||
});
|
||||
|
||||
test('Loading an AMD bundle', function () {
|
||||
System.config({
|
||||
map: {
|
||||
helloworld: './'
|
||||
},
|
||||
packages: {
|
||||
helloworld: {
|
||||
main: './helloworld.js',
|
||||
defaultExtension: false
|
||||
}
|
||||
}
|
||||
});
|
||||
System.config({
|
||||
bundles: {
|
||||
'tests/amd-bundle.js': ['bundle-*']
|
||||
@ -591,6 +619,8 @@ suite('SystemJS Standard Tests', function() {
|
||||
|
||||
test('CommonJS require.resolve', function () {
|
||||
return System.import('tests/cjs-resolve.js').then(function (m) {
|
||||
console.log(':' + m);
|
||||
console.log(m.substr(m.length - 12, 12));
|
||||
ok(m.substr(m.length - 12, 12) == 'test/tests/a');
|
||||
});
|
||||
})
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user