Skip to content

Commit f3ce496

Browse files
fix: dont match linebreaks (#214)
* fix: dont match linebreaks * Update __tests__/index.test.jsx Co-authored-by: Jon Ursenbach <erunion@users.noreply.github.com>
1 parent b28a954 commit f3ce496

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

__tests__/index.test.jsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,4 +224,10 @@ describe('VARIABLE_REGEXP', () => {
224224
it('should match against colons with non-english characters', () => {
225225
expect('<<glossary:ラベル>>').toMatch(new RegExp(VARIABLE_REGEXP));
226226
});
227+
228+
it('should NOT match against newlines', () => {
229+
expect('<<what the\nfuck>>').not.toMatch(new RegExp(VARIABLE_REGEXP));
230+
expect('<<what the\rfuck>>').not.toMatch(new RegExp(VARIABLE_REGEXP));
231+
expect('<<what the\r\nfuck>>').not.toMatch(new RegExp(VARIABLE_REGEXP));
232+
});
227233
});

index.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,6 @@ module.exports.Variable = Variable;
185185
// - \<<apiKey\>> - escaped variables
186186
// - <<apiKey>> - regular variables
187187
// - <<glossary:glossary items>> - glossary
188-
module.exports.VARIABLE_REGEXP = /(?:\\)?<<([-_\p{L}:.\s\d]+)(?:\\)?>>/iu.source;
188+
module.exports.VARIABLE_REGEXP = /(?:\\)?<<((?:(?![\r\n])[-_\p{L}:.\s\d])+)(?:\\)?>>/iu.source;
189189
module.exports.VariablesContext = VariablesContext;
190190
module.exports.SelectedAppContext = SelectedAppContext;

0 commit comments

Comments
 (0)