Supports spaces in author filtering
All checks were successful
EpicKnarvik97/Books-Without-Borders/pipeline/head This commit looks good
All checks were successful
EpicKnarvik97/Books-Without-Borders/pipeline/head This commit looks good
This commit is contained in:
@@ -48,6 +48,27 @@ public abstract class BookIndex {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Parse book author from input
|
||||||
|
for (int i = 0; i < arguments.length; i++) {
|
||||||
|
String author = InputCleaningHelper.parseAuthorSpecifier(arguments[i]);
|
||||||
|
if (author == null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
for (int j = i + 1; j < arguments.length; j++) {
|
||||||
|
int pageNumber = InputCleaningHelper.parsePageNumber(arguments[j]);
|
||||||
|
if (pageNumber > 0) {
|
||||||
|
int authorEnd = j - 1;
|
||||||
|
StringBuilder builder = new StringBuilder(author);
|
||||||
|
for (int k = i + 1; k <= authorEnd; k++) {
|
||||||
|
builder.append(" ").append(arguments[k]);
|
||||||
|
}
|
||||||
|
AuthorBookIndex.printBooks(sender, selectPublic, command, pageNumber, builder.toString());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -78,7 +78,7 @@ public final class InputCleaningHelper {
|
|||||||
*/
|
*/
|
||||||
@Nullable
|
@Nullable
|
||||||
public static String parseAuthorSpecifier(@NotNull String input) {
|
public static String parseAuthorSpecifier(@NotNull String input) {
|
||||||
Pattern pattern = Pattern.compile("author([0-9a-zA-Z_]+)");
|
Pattern pattern = Pattern.compile("author([\\p{L}0-9_.,!#%&'`^@$+]+)");
|
||||||
Matcher matcher = pattern.matcher(input);
|
Matcher matcher = pattern.matcher(input);
|
||||||
if (matcher.matches()) {
|
if (matcher.matches()) {
|
||||||
return matcher.group(1);
|
return matcher.group(1);
|
||||||
|
Reference in New Issue
Block a user