context.asset should pass-through absolute URLs

This commit is contained in:
Bryan Housel
2020-01-29 15:22:06 -05:00
parent 89724cfb1b
commit 9154a6a554
2 changed files with 5 additions and 0 deletions
+1
View File
@@ -405,6 +405,7 @@ export function coreContext() {
};
context.asset = (val) => {
if (/^http(s)?:\/\//i.test(val)) return val;
const filename = _assetPath + val;
return _assetMap[filename] || filename;
};
+4
View File
@@ -29,6 +29,10 @@ describe('iD.coreContext', function() {
context = iD.coreContext().assetPath('iD/').assetMap(assets);
});
it('ignores absolute urls', function() {
expect(context.asset('HTTP://hello')).to.eql('HTTP://hello');
expect(context.asset('https://world')).to.eql('https://world');
});
it('looks first in assetMap', function() {
expect(context.asset('img/loader.gif')).to.eql('/assets/iD/img/loader-b66184b5c4afbccc25f.gif');
});