mirror of
https://github.com/zero-peak/ZeroOmega.git
synced 2025-02-02 02:58:13 -05:00
Escape back slashes in shExp2RegExp. Add unit tests. Fix #473.
This commit is contained in:
parent
a80489c95c
commit
55fba179f0
@ -1,6 +1,6 @@
|
|||||||
module.exports = exports =
|
module.exports = exports =
|
||||||
regExpMetaChars: do ->
|
regExpMetaChars: do ->
|
||||||
chars = '''[\^$.|?*+(){}/'''
|
chars = '''\\[\^$.|?*+(){}/'''
|
||||||
set = {}
|
set = {}
|
||||||
for i in [0...chars.length]
|
for i in [0...chars.length]
|
||||||
set[chars.charCodeAt(i)] = true
|
set[chars.charCodeAt(i)] = true
|
||||||
|
@ -13,3 +13,7 @@ describe 'ShexpUtils', ->
|
|||||||
it 'should know the difference between escaped and unescaped slashes', ->
|
it 'should know the difference between escaped and unescaped slashes', ->
|
||||||
regex = ShexpUtils.escapeSlash '\\\\/\\/test\\/'
|
regex = ShexpUtils.escapeSlash '\\\\/\\/test\\/'
|
||||||
regex.should.equal '\\\\\\/\\/test\\/'
|
regex.should.equal '\\\\\\/\\/test\\/'
|
||||||
|
describe '#shExp2RegExp', ->
|
||||||
|
it 'should escape regex meta chars and back slashes', ->
|
||||||
|
regex = ShexpUtils.shExp2RegExp 'this.is|a\\test+'
|
||||||
|
regex.should.equal '^this\\.is\\|a\\\\test\\+$'
|
||||||
|
Loading…
Reference in New Issue
Block a user