Detect all wild cards and escaped wild cards in likify
issue10020 review320611002
This commit is contained in:
1 parent
2ee13ba9f9
commit
0921f01ba3
2 files changed
+24
-3
No files matched your search
+6
-3
@@ -1804,12 +1804,15 @@
|
||||
}.bind(this));
|
||||
return result;
|
||||
},
|
||||
likify: function(value) {
|
||||
likify: function(value, escape) {
|
||||
escape = escape || '\\';
|
||||
if (!value) {
|
||||
return '%';
|
||||
}
|
||||
var escaped = value.replace('%%', '__');
|
||||
if (escaped.contains('%')) {
|
||||
var escaped = value
|
||||
.replace(escape + '%', '')
|
||||
.replace(escape + '_', '');
|
||||
if (escaped.contains('%') || escaped.contains('_')) {
|
||||
return value;
|
||||
} else {
|
||||
return '%' + value + '%';
|
||||
|
||||
@@ -1531,6 +1531,24 @@
|
||||
});
|
||||
});
|
||||
|
||||
QUnit.test('DomainParser.likify', function() {
|
||||
var parser = new Sao.common.DomainParser();
|
||||
|
||||
[
|
||||
['', '%'],
|
||||
['foo', '%foo%'],
|
||||
['foo%', 'foo%'],
|
||||
['foo_bar', 'foo_bar'],
|
||||
['foo\\%', '%foo\\%%'],
|
||||
['foo\\_bar', '%foo\\_bar%'],
|
||||
].forEach(function(test) {
|
||||
var value = test[0];
|
||||
var result = test[1];
|
||||
QUnit.ok(Sao.common.compare(parser.likify(value), result),
|
||||
'likify(' + JSON.stringify(value) + ')');
|
||||
});
|
||||
});
|
||||
|
||||
QUnit.test('DomainParser.quote', function() {
|
||||
var parser = new Sao.common.DomainParser();
|
||||
|
||||
|
||||
Reference in new issue
Block a user