File tree Expand file tree Collapse file tree 2 files changed +8
-1
lines changed
Expand file tree Collapse file tree 2 files changed +8
-1
lines changed Original file line number Diff line number Diff line change @@ -279,4 +279,11 @@ describe('MDX_VARIABLE_REGEXP', () => {
279279 expect ( '{user.what_the\rfuck}' ) . not . toMatch ( new RegExp ( MDX_VARIABLE_REGEXP ) ) ;
280280 expect ( '{user.what_the\r\nfuck}' ) . not . toMatch ( new RegExp ( MDX_VARIABLE_REGEXP ) ) ;
281281 } ) ;
282+
283+ it ( 'should NOT match JS template literals without a dot after user' , ( ) => {
284+ // Bug case: {userXYZ} should not match as if it were {user.XYZ}
285+ expect ( '{userEndpoint}' ) . not . toMatch ( new RegExp ( MDX_VARIABLE_REGEXP ) ) ;
286+ expect ( '{userXYZ}' ) . not . toMatch ( new RegExp ( MDX_VARIABLE_REGEXP ) ) ;
287+ expect ( '{baseUrl}' ) . not . toMatch ( new RegExp ( MDX_VARIABLE_REGEXP ) ) ;
288+ } ) ;
282289} ) ;
Original file line number Diff line number Diff line change @@ -204,7 +204,7 @@ module.exports.VARIABLE_REGEXP = /(?:\\)?<<((?:(?![\r\n])[-_\p{L}:.\s\d])+)(?:\\
204204 * @see {@link https://stackoverflow.com/a/6926184 }
205205 */
206206module . exports . MDX_VARIABLE_REGEXP =
207- / ( \\ ) ? \{ u s e r .( [ $ _ \p{ L} ] [ $ _ \p{ L} \p{ Mn} \p{ Mc} \p{ Nd} \p{ Pc} \u200C \u200D ] * ) ( \\ ) ? \} / iu. source ;
207+ / ( \\ ) ? \{ u s e r \ .( [ $ _ \p{ L} ] [ $ _ \p{ L} \p{ Mn} \p{ Mc} \p{ Nd} \p{ Pc} \u200C \u200D ] * ) ( \\ ) ? \} / iu. source ;
208208
209209module . exports . VariablesContext = VariablesContext ;
210210module . exports . SelectedAppContext = SelectedAppContext ;
You can’t perform that action at this time.
0 commit comments