diff --git a/index.js b/index.js index d8d93cf..5f0a6c5 100644 --- a/index.js +++ b/index.js @@ -70,7 +70,7 @@ module.exports = function(schema, options) { // Wrap with case-insensitivity if (get(path, 'options.uniqueCaseInsensitive') || indexOptions.uniqueCaseInsensitive) { - // Escapse RegExp chars + // Escape RegExp chars pathValue = pathValue.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, '\\$&'); pathValue = new RegExp('^' + pathValue + '$', 'i'); } diff --git a/test/tests/validation.spec.js b/test/tests/validation.spec.js index 0f661d7..46aecb6 100644 --- a/test/tests/validation.spec.js +++ b/test/tests/validation.spec.js @@ -22,7 +22,7 @@ module.exports = function(mongoose) { promise.catch(done); }); - it('allow unique records with regex wildcards', function(done) { + it('allows unique records with regex wildcards', function(done) { var User = mongoose.model('User', helpers.createUserCaseInsensitiveSchema().plugin(uniqueValidator)); // Save the first user