mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-11 16:05:44 +01:00
merge with issue-441
This commit is contained in:
@@ -45,6 +45,7 @@ import java.util.Collection;
|
|||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@@ -197,7 +198,7 @@ public final class SearchUtil
|
|||||||
query = query.toLowerCase(Locale.ENGLISH);
|
query = query.toLowerCase(Locale.ENGLISH);
|
||||||
}
|
}
|
||||||
|
|
||||||
query = query.replace("*", ".*").replace("?", ".");
|
query = query.replace("\\", "\\\\").replace("*", ".*").replace("?", ".");
|
||||||
query = ".*".concat(query).concat(".*");
|
query = ".*".concat(query).concat(".*");
|
||||||
|
|
||||||
if (request.isIgnoreCase())
|
if (request.isIgnoreCase())
|
||||||
|
|||||||
@@ -54,11 +54,9 @@ public class SearchUtilTest
|
|||||||
public void testMultiMatchesAll()
|
public void testMultiMatchesAll()
|
||||||
{
|
{
|
||||||
assertTrue(SearchUtil.matchesAll(new SearchRequest("test"), "test",
|
assertTrue(SearchUtil.matchesAll(new SearchRequest("test"), "test",
|
||||||
"test hello", "hello test",
|
"test hello", "hello test", "hello test hello"));
|
||||||
"hello test hello"));
|
|
||||||
assertFalse(SearchUtil.matchesAll(new SearchRequest("test"), "test",
|
assertFalse(SearchUtil.matchesAll(new SearchRequest("test"), "test",
|
||||||
"test hello", "hello test",
|
"test hello", "hello test", "hello test hello", "ka"));
|
||||||
"hello test hello", "ka"));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -69,11 +67,9 @@ public class SearchUtilTest
|
|||||||
public void testMultiMatchesOne()
|
public void testMultiMatchesOne()
|
||||||
{
|
{
|
||||||
assertTrue(SearchUtil.matchesOne(new SearchRequest("test"), "test",
|
assertTrue(SearchUtil.matchesOne(new SearchRequest("test"), "test",
|
||||||
"test hello", "hello test",
|
"test hello", "hello test", "hello test hello"));
|
||||||
"hello test hello"));
|
|
||||||
assertTrue(SearchUtil.matchesOne(new SearchRequest("test"), "test",
|
assertTrue(SearchUtil.matchesOne(new SearchRequest("test"), "test",
|
||||||
"test hello", "hello test",
|
"test hello", "hello test", "hello test hello", "ka"));
|
||||||
"hello test hello", "ka"));
|
|
||||||
assertTrue(SearchUtil.matchesOne(new SearchRequest("test"), "hans", "uew",
|
assertTrue(SearchUtil.matchesOne(new SearchRequest("test"), "hans", "uew",
|
||||||
"klaus", "hello test hello", "ka"));
|
"klaus", "hello test hello", "ka"));
|
||||||
}
|
}
|
||||||
@@ -162,6 +158,27 @@ public class SearchUtilTest
|
|||||||
"heLLo te heLLo"));
|
"heLLo te heLLo"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test for issue 441
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testSpecialCharacter()
|
||||||
|
{
|
||||||
|
assertTrue(SearchUtil.matchesAll(new SearchRequest("test\\hansolo"),
|
||||||
|
"test\\hansolo"));
|
||||||
|
assertTrue(SearchUtil.matchesAll(new SearchRequest("*\\hansolo"),
|
||||||
|
"test\\hansolo"));
|
||||||
|
assertTrue(SearchUtil.matchesAll(new SearchRequest("test\\*"),
|
||||||
|
"test\\hansolo"));
|
||||||
|
assertTrue(SearchUtil.matchesAll(new SearchRequest("test\\hansolo"),
|
||||||
|
"abc test\\hansolo abc"));
|
||||||
|
assertFalse(SearchUtil.matchesAll(new SearchRequest("test\\hansolo"),
|
||||||
|
"testhansolo"));
|
||||||
|
assertFalse(SearchUtil.matchesAll(new SearchRequest("test\\hansolo"),
|
||||||
|
"test\\hnsolo"));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method description
|
* Method description
|
||||||
*
|
*
|
||||||
|
|||||||
Reference in New Issue
Block a user