Skip to content

Commit

Permalink
Escape back slashes in shExp2RegExp. Add unit tests. Fix #473.
Browse files Browse the repository at this point in the history
  • Loading branch information
FelisCatus committed May 22, 2015
1 parent a80489c commit 55fba17
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion omega-pac/src/shexp_utils.coffee
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module.exports = exports =
regExpMetaChars: do ->
chars = '''[\^$.|?*+(){}/'''
chars = '''\\[\^$.|?*+(){}/'''
set = {}
for i in [0...chars.length]
set[chars.charCodeAt(i)] = true
Expand Down
4 changes: 4 additions & 0 deletions omega-pac/test/shexp_utils.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -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\\+$'

0 comments on commit 55fba17

Please sign in to comment.