File tree Expand file tree Collapse file tree 1 file changed +17
-11
lines changed Expand file tree Collapse file tree 1 file changed +17
-11
lines changed Original file line number Diff line number Diff line change @@ -301,17 +301,19 @@ function process_layer(layer) {
301301 }
302302
303303 if ( ! isEmpty ( text ) ) {
304- var re = / \$ \( [ a - z A - Z ] \w * \) / g;
305- var start = 0 ;
306- var textSource = smart_escape ( decodeURIComponent ( text ) , / [ , \/ ] / g) ;
307- text = "" ;
308- for ( var res = re . exec ( textSource ) ; res ; res = re . exec ( textSource ) ) {
309- text += smart_escape ( textSource . slice ( start , res . index ) ) ;
310- text += res [ 0 ] ;
311- start = res . index + res [ 0 ] . length ;
312- }
313- text += encodeURIComponent ( textSource . slice ( start ) ) ;
314- components . push ( text ) ;
304+ var variablesRegex = new RegExp ( / ( \$ \( [ a - z A - Z ] \w + \) ) / g) ;
305+ var textDividedByVariables = text . split ( variablesRegex ) . filter ( function ( x ) {
306+ return x ;
307+ } ) ;
308+ var encodedParts = textDividedByVariables . map ( function ( subText ) {
309+ var matches = variablesRegex [ Symbol . match ] ( subText ) ;
310+ var isVariable = matches ? matches . length > 0 : false ;
311+ if ( isVariable ) {
312+ return subText ;
313+ }
314+ return encodeCurlyBraces ( encodeURIComponent ( smart_escape ( subText , new RegExp ( / ( [ , \/ ] ) / g) ) ) ) ;
315+ } ) ;
316+ components . push ( encodedParts . join ( '' ) ) ;
315317 }
316318 } else if ( type === 'fetch' ) {
317319 var encodedUrl = base64EncodeURL ( fetchUrl ) ;
@@ -324,6 +326,10 @@ function process_layer(layer) {
324326 return components . join ( ':' ) ;
325327}
326328
329+ function encodeCurlyBraces ( input ) {
330+ return input . replaceAll ( '(' , '%28' ) . replaceAll ( ')' , '%29' ) ;
331+ }
332+
327333/**
328334 * Parse radius options
329335 * @private
You can’t perform that action at this time.
0 commit comments