1 | ;
|
2 |
|
3 | const _ = require(`lodash`);
|
4 |
|
5 | module.exports = str => {
|
6 | const exploded = str.split(`/`);
|
7 | const regex = new RegExp(exploded.slice(1, -1).join(`/`) // Double escaping is needed to get past the GraphQL parser,
|
8 | // but single escaping is needed for the RegExp constructor,
|
9 | // i.e. `"\\\\w+"` for `/\w+/`.
|
10 | .replace(/\\\\/, `\\`), _.last(exploded));
|
11 | return regex;
|
12 | };
|
13 | //# sourceMappingURL=prepare-regex.js.map |
\ | No newline at end of file |