Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions __tests__/index.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -224,4 +224,10 @@ describe('VARIABLE_REGEXP', () => {
it('should match against colons with non-english characters', () => {
expect('<<glossary:ラベル>>').toMatch(new RegExp(VARIABLE_REGEXP));
});

it('should NOT match against newlines', () => {
expect('<<what the\nfuck>>').not.toMatch(new RegExp(VARIABLE_REGEXP));
expect('<<what the\rfuck>>').not.toMatch(new RegExp(VARIABLE_REGEXP));
expect('<<what the\r\nfuck>>').not.toMatch(new RegExp(VARIABLE_REGEXP));
});
});
2 changes: 1 addition & 1 deletion index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,6 @@ module.exports.Variable = Variable;
// - \<<apiKey\>> - escaped variables
// - <<apiKey>> - regular variables
// - <<glossary:glossary items>> - glossary
module.exports.VARIABLE_REGEXP = /(?:\\)?<<([-_\p{L}:.\s\d]+)(?:\\)?>>/iu.source;
module.exports.VARIABLE_REGEXP = /(?:\\)?<<((?:(?![\r\n])[-_\p{L}:.\s\d])+)(?:\\)?>>/iu.source;
module.exports.VariablesContext = VariablesContext;
module.exports.SelectedAppContext = SelectedAppContext;