File tree Expand file tree Collapse file tree 2 files changed +5
-11
lines changed Expand file tree Collapse file tree 2 files changed +5
-11
lines changed Original file line number Diff line number Diff line change 1
1
{
2
2
"name" : " wurd" ,
3
- "version" : " 7.0.0 " ,
3
+ "version" : " 7.0.1 " ,
4
4
"description" : " Wurd CMS client for Node" ,
5
5
"repository" : {
6
6
"type" : " git" ,
Original file line number Diff line number Diff line change 3
3
*
4
4
* @return {String }
5
5
*/
6
- exports . encodeQueryString = function ( data ) {
6
+ exports . encodeQueryString = function ( data ) {
7
7
let parts = Object . keys ( data ) . map ( key => {
8
8
let value = data [ key ] ;
9
9
@@ -22,16 +22,10 @@ exports.encodeQueryString = function(data) {
22
22
*
23
23
* @return {String }
24
24
*/
25
- exports . replaceVars = function ( text , vars = { } ) {
25
+ exports . replaceVars = function ( text , vars = { } ) {
26
26
if ( typeof text !== 'string' ) return text ;
27
27
28
- Object . keys ( vars ) . forEach ( key => {
29
- let val = vars [ key ] ;
30
-
31
- text = text . replace ( new RegExp ( `{{${ key } }}` , 'g' ) , val ) ;
32
- } ) ;
33
-
34
- return text ;
28
+ return text . replace ( / { { ( [ \w . - ] + ) } } / g, ( _ , key ) => vars [ key ] || '' ) ;
35
29
} ;
36
30
37
31
@@ -43,7 +37,7 @@ exports.replaceVars = function(text, vars = {}) {
43
37
*
44
38
* @return {String } cacheId
45
39
*/
46
- exports . getCacheId = function ( id , options = { } ) {
40
+ exports . getCacheId = function ( id , options = { } ) {
47
41
let lang = options . lang || ''
48
42
49
43
return `${ lang } /${ id } ` ;
You can’t perform that action at this time.
0 commit comments