Supports spaces in author filtering
All checks were successful
EpicKnarvik97/Books-Without-Borders/pipeline/head This commit looks good

This commit is contained in:
2025-08-08 12:07:18 +02:00
parent a986411990
commit b963f83dee
2 changed files with 22 additions and 1 deletions

View File

@@ -48,6 +48,27 @@ public abstract class BookIndex {
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;
}

View File

@@ -78,7 +78,7 @@ public final class InputCleaningHelper {
*/
@Nullable
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);
if (matcher.matches()) {
return matcher.group(1);