UNPKG

327 BJavaScriptView Raw
1'use strict';
2
3/**
4 * For consistency's sake, we replace positional operator `$` and array filters
5 * `$[]` and `$[foo]` with `0` when looking up schema paths.
6 */
7
8module.exports = function cleanPositionalOperators(path) {
9 return path.
10 replace(/\.\$(\[[^\]]*\])?\./g, '.0.').
11 replace(/\.(\[[^\]]*\])?\$$/g, '.0');
12};
\No newline at end of file