mirror of
https://github.com/zero-peak/ZeroOmega.git
synced 2025-01-22 15:08:12 -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 =
|
||||
regExpMetaChars: do ->
|
||||
chars = '''[\^$.|?*+(){}/'''
|
||||
chars = '''\\[\^$.|?*+(){}/'''
|
||||
set = {}
|
||||
for i in [0...chars.length]
|
||||
set[chars.charCodeAt(i)] = true
|
||||
|
@ -13,3 +13,7 @@ describe 'ShexpUtils', ->
|
||||
it 'should know the difference between escaped and unescaped slashes', ->
|
||||
regex = ShexpUtils.escapeSlash '\\\\/\\/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