Skip to content
This repository was archived by the owner on Sep 5, 2024. It is now read-only.

Commit bc71d0b

Browse files
committed
fix(util): sanitize function used by select and autocomplete throws
Fixes #11908
1 parent a3a977a commit bc71d0b

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

src/core/util/util.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1009,7 +1009,7 @@ function UtilFactory($document, $timeout, $compile, $rootScope, $$mdAnimate, $in
10091009
*/
10101010
sanitize: function(term) {
10111011
if (!term) return term;
1012-
return term.replace(/[\\^$*+?.()|{}[]]/g, '\\$&');
1012+
return term.replace(/[\\^$*+?.()|{}[]/g, '\\$&');
10131013
}
10141014
};
10151015

src/core/util/util.spec.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -760,12 +760,14 @@ describe('util', function() {
760760
$mdUtil = _$mdUtil_;
761761
}));
762762

763-
it('Removes Regex indentifiers in a text', function() {
764-
765-
// eslint-disable-next-line no-useless-escape
766-
var myText = '\+98';
763+
it('sanitizes + signs', function() {
764+
var myText = '+98';
765+
expect($mdUtil.sanitize(myText)).toEqual('\\+98');
766+
});
767767

768-
expect($mdUtil.sanitize(myText)).toEqual('+98');
768+
it('sanitizes parenthesis', function() {
769+
var myText = '()';
770+
expect($mdUtil.sanitize(myText)).toEqual('\\(\\)');
769771
});
770772
});
771773
});

0 commit comments

Comments
 (0)