diff --git a/index.js b/index.js index 23ac15c..c4abc95 100644 --- a/index.js +++ b/index.js @@ -282,6 +282,7 @@ export function hasProperty(object, path) { return true; } +// TODO: Backslashes with no effect should not be escaped export function escapePath(path) { if (typeof path !== 'string') { throw new TypeError('Expected a string'); diff --git a/test.js b/test.js index 8c1c45a..556d810 100644 --- a/test.js +++ b/test.js @@ -397,6 +397,10 @@ test('escapePath', t => { t.is(escapePath('foo[0].bar'), 'foo\\[0]\\.bar'); t.is(escapePath('foo.bar[0].baz'), 'foo\\.bar\\[0]\\.baz'); t.is(escapePath('[0].foo'), '\\[0]\\.foo'); + // TODO: The following three tests assume that backslashes with no effect are escaped. Update when this changes. + t.is(escapePath('\\foo'), '\\\\foo'); + t.is(escapePath('foo\\'), 'foo\\\\'); + t.is(escapePath('foo\\\\'), 'foo\\\\\\\\'); t.is(escapePath(''), ''); t.throws(() => {