TileLayer feature: add space to character regex for template to allow Object keys with it (#7216)

This commit is contained in:
Lubomír Bucek
2020-11-18 15:25:14 +01:00
committed by GitHub
parent f22422a402
commit 92ff0a1461
2 changed files with 3 additions and 2 deletions

View File

@ -229,9 +229,10 @@ describe('Util', function () {
}).to.throwError();
});
it('allows underscores and dashes in placeholders', function () {
it('allows underscores, dashes and spaces in placeholders', function () {
expect(L.Util.template('{nice_stuff}', {'nice_stuff': 'foo'})).to.eql('foo');
expect(L.Util.template('{-y}', {'-y': 1})).to.eql('1');
expect(L.Util.template('{Day Of Month}', {'Day Of Month': 30})).to.eql('30');
});
});

View File

@ -152,7 +152,7 @@ export function getParamString(obj, existingUrl, uppercase) {
return ((!existingUrl || existingUrl.indexOf('?') === -1) ? '?' : '&') + params.join('&');
}
var templateRe = /\{ *([\w_-]+) *\}/g;
var templateRe = /\{ *([\w_ -]+) *\}/g;
// @function template(str: String, data: Object): String
// Simple templating facility, accepts a template string of the form `'Hello {a}, {b}'`