UNPKG

428 BJavaScriptView Raw
1"use strict";
2
3const _ = require(`lodash`);
4
5module.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