Fixed issue where search did not match exact the complete URL and added support for multi-word search strings

This commit is contained in:
Rohit Awate 2018-03-17 21:56:30 +05:30
parent a679c6d1a2
commit 7f3a4e7343
No known key found for this signature in database
GPG key ID: 9C04E52F6B625A85
3 changed files with 17 additions and 6 deletions

View file

@ -52,10 +52,10 @@ public class HistoryItemController implements Initializable {
searchString = searchString.toLowerCase();
String comparisonString;
// Checks if matches with HTTP method
comparisonString = dashboardState.getHttpMethod().toLowerCase();
// Checks if matches with target
comparisonString = dashboardState.getTarget().toString().toLowerCase();
if (comparisonString.contains(searchString))
return 7;
return 10;
// Checks if matches with target's hostname
comparisonString = dashboardState.getTarget().getHost().toLowerCase();
@ -67,6 +67,11 @@ public class HistoryItemController implements Initializable {
if (comparisonString.contains(searchString))
return 9;
// Checks if matches with HTTP method
comparisonString = dashboardState.getHttpMethod().toLowerCase();
if (comparisonString.contains(searchString))
return 7;
// Checks for a match in the params
for (Map.Entry param : dashboardState.getParams().entrySet()) {
if (param.getKey().toString().toLowerCase().contains(searchString) ||

View file

@ -262,7 +262,15 @@ public class HomeWindowController implements Initializable {
List<HistoryItemController> filteredList = new ArrayList<>();
for (HistoryItemController controller : historyItemControllers) {
if (controller.getRelativityIndex(searchString) != 0)
int relativityIndex = 0;
// Split the string into words and get total relativity index as sum of individual indices.
String words[] = searchString.split("\\s");
for (String word : words)
relativityIndex += controller.getRelativityIndex(word);
if (relativityIndex != 0)
filteredList.add(controller);
}

View file

@ -200,8 +200,6 @@ public class HistoryManager {
}
} catch (SQLException e) {
Services.loggingService.logWarning("Database error.", e, LocalDateTime.now());
} finally {
System.out.println("Saved history item to database.");
}
}, "History Saver Thread").start();