diff --git a/omega-pac/src/shexp_utils.coffee b/omega-pac/src/shexp_utils.coffee index 05931c75..27d78b46 100644 --- a/omega-pac/src/shexp_utils.coffee +++ b/omega-pac/src/shexp_utils.coffee @@ -1,6 +1,6 @@ module.exports = exports = regExpMetaChars: do -> - chars = '''[\^$.|?*+(){}/''' + chars = '''\\[\^$.|?*+(){}/''' set = {} for i in [0...chars.length] set[chars.charCodeAt(i)] = true diff --git a/omega-pac/test/shexp_utils.coffee b/omega-pac/test/shexp_utils.coffee index 56452cc1..e94af060 100644 --- a/omega-pac/test/shexp_utils.coffee +++ b/omega-pac/test/shexp_utils.coffee @@ -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\\+$'