diff --git a/umap/static/umap/js/umap.core.js b/umap/static/umap/js/umap.core.js index 0584fd31..fb85a047 100644 --- a/umap/static/umap/js/umap.core.js +++ b/umap/static/umap/js/umap.core.js @@ -174,7 +174,7 @@ L.Util.greedyTemplate = (str, data, ignore) => { } return str.replace( - /\{ *([\w_\:\.\|@]+)(?:\|("[^"]*"))? *\}/g, + /\{ *([^\{\}/\-]+)(?:\|("[^"]*"))? *\}/g, (str, key, staticFallback) => { const vars = key.split('|') let value diff --git a/umap/static/umap/test/Util.js b/umap/static/umap/test/Util.js index 45800e98..57c75b2d 100644 --- a/umap/static/umap/test/Util.js +++ b/umap/static/umap/test/Util.js @@ -245,6 +245,25 @@ describe('L.Util', function () { ) }) + it('should accept space', function () { + assert.equal( + L.Util.greedyTemplate('A phrase with a {var iable}.', { + 'var iable': 'value', + }), + 'A phrase with a value.' + ) + }) + + it('should accept non ascii chars', function () { + assert.equal( + L.Util.greedyTemplate('A phrase with a {Accessibilité} and {переменная}.', { + 'Accessibilité': 'value', + 'переменная': 'another', + }), + 'A phrase with a value and another.' + ) + }) + it('should replace even with ignore if key is found', function () { assert.equal( L.Util.greedyTemplate(