mirror of
https://github.com/FoggedLens/iD.git
synced 2026-05-14 21:28:11 +02:00
context.asset should pass-through absolute URLs
This commit is contained in:
@@ -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;
|
||||
};
|
||||
|
||||
@@ -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');
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user