Skip to content
This repository was archived by the owner on May 14, 2024. It is now read-only.

Commit aadb347

Browse files
committed
Fix issue #8
1 parent 2f5fd6b commit aadb347

File tree

3 files changed

+21
-8
lines changed

3 files changed

+21
-8
lines changed

lib/string-parsing/escape-substring.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
'use strict'
22

3-
const escapeFilterValue = require('../utils/escape-filter-value')
4-
53
/**
64
* In an extensible filter, the righthand size of the filter can have
75
* substrings delimeted by `*` characters, e.g. `foo=*foo*bar*baz*`. This
@@ -25,9 +23,9 @@ module.exports = function escapeSubstring (str) {
2523
throw Error('extensible filter delimiter missing')
2624
}
2725

28-
out.initial = escapeFilterValue(fields.shift())
29-
out.final = escapeFilterValue(fields.pop())
30-
Array.prototype.push.apply(out.any, fields.map(escapeFilterValue))
26+
out.initial = fields.shift()
27+
out.final = fields.pop()
28+
Array.prototype.push.apply(out.any, fields)
3129

3230
return out
3331
}

lib/string-parsing/escape-substring.test.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,25 @@ tap.test('throws if separator missing', async t => {
1111
})
1212

1313
tap.test('escapes an initial only string', async t => {
14-
const expected = { initial: 'f\\28o', final: '', any: [] }
14+
const expected = { initial: 'f(o', final: '', any: [] }
1515
const result = escapeSubstring('f(o*')
1616
t.strictSame(expected, result)
1717
})
1818

1919
tap.test('escapes string with initial and final', async t => {
20-
const expected = { initial: 'f\\28o', final: 'bar', any: [] }
20+
const expected = { initial: 'f(o', final: 'bar', any: [] }
2121
const result = escapeSubstring('f(o*bar')
2222
t.strictSame(expected, result)
2323
})
2424

2525
tap.test('escapes string with initial, final, and any', async t => {
26-
const expected = { initial: 'f\\28o', final: 'b\\29f', any: ['bar', 'baz'] }
26+
const expected = { initial: 'f(o', final: 'b)f', any: ['bar', 'baz'] }
2727
const result = escapeSubstring('f(o*bar*baz*b)f')
2828
t.strictSame(expected, result)
2929
})
30+
31+
tap.test('escapes string with any only and containing a non ascii character', async t => {
32+
const expected = { initial: '', final: '', any: ['réseau'] }
33+
const result = escapeSubstring('*réseau*')
34+
t.strictSame(expected, result)
35+
})

lib/string-parsing/parse-expression.test.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,5 +102,14 @@ tap.test('parses filter with non-ascii characters', t => {
102102
t.equal(result.toString(), '(cn=\\c3\\b8)')
103103
})
104104

105+
t.test('*réseau*', async t => {
106+
const result = parse('cn=*réseau*')
107+
t.type(result, SubstringFilter)
108+
t.equal(result.toString(), '(cn=*r\\c3\\a9seau*)')
109+
t.equal(result.initial, '')
110+
t.equal(result.final, '')
111+
t.strictSame(result.any, ['réseau'])
112+
})
113+
105114
t.end()
106115
})

0 commit comments

Comments
 (0)