-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #359 from center-for-threat-informed-defense/280-a…
…dd-documentdb-interoperability 280 add documentdb interoperability
- Loading branch information
Showing
42 changed files
with
4,200 additions
and
3,907 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,17 @@ | ||
'use strict'; | ||
|
||
const logger = require('../lib/logger'); | ||
|
||
exports.sanitizeRegex = function (expression) { | ||
// Compile the expression. If it's valid, return the expression. Otherwise, return an empty string. | ||
try { | ||
// Escapes all regex characters so they are treated like literal characters rather than special regex characters | ||
// eslint-disable-next-line no-useless-escape | ||
expression = expression.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); | ||
// eslint-disable-next-line no-new | ||
new RegExp(expression); | ||
return expression; | ||
} catch (err) { | ||
logger.warn(err); | ||
return ''; | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.