aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2018-05-04 00:28:20 +0300
committerGravatar Vitaly Takmazov2018-05-04 00:28:20 +0300
commit651fe36c3544aa14f13e71c71832d630f3539fb9 (patch)
tree034bfc3e7bdaee8e335751562ae32bb42c806378
parentd29d010472c1f82e40d1afa227f651fd74575212 (diff)
CommandsManager: strip whitespace from command start
-rw-r--r--juick-common/src/main/java/com/juick/server/CommandsManager.java3
-rw-r--r--juick-server/src/test/java/com/juick/server/tests/ServerTests.java2
2 files changed, 3 insertions, 2 deletions
diff --git a/juick-common/src/main/java/com/juick/server/CommandsManager.java b/juick-common/src/main/java/com/juick/server/CommandsManager.java
index 1907bde7..5927ed3a 100644
--- a/juick-common/src/main/java/com/juick/server/CommandsManager.java
+++ b/juick-common/src/main/java/com/juick/server/CommandsManager.java
@@ -77,7 +77,8 @@ public class CommandsManager {
@Inject
private ImagesService imagesService;
- public CommandResult processCommand(User user, String input, @Nonnull URI attachment) throws Exception {
+ public CommandResult processCommand(User user, String data, @Nonnull URI attachment) throws Exception {
+ String input = StringUtils.stripStart(data, null);
Optional<Method> cmd = MethodUtils.getMethodsListWithAnnotation(getClass(), UserCommand.class).stream()
.filter(m -> Pattern.compile(m.getAnnotation(UserCommand.class).pattern(),
m.getAnnotation(UserCommand.class).patternFlags()).matcher(input).matches())
diff --git a/juick-server/src/test/java/com/juick/server/tests/ServerTests.java b/juick-server/src/test/java/com/juick/server/tests/ServerTests.java
index 4a495a6e..c0501661 100644
--- a/juick-server/src/test/java/com/juick/server/tests/ServerTests.java
+++ b/juick-server/src/test/java/com/juick/server/tests/ServerTests.java
@@ -723,7 +723,7 @@ public class ServerTests {
assertEquals("should be second reply", expectedSecondReply,
commandsManager.processCommand(user, "#" + mid + " yoyo", URI.create("http://static.juick.com/settings/facebook.png")).getText());
assertEquals("should be third reply", expectedThirdReply,
- commandsManager.processCommand(user, "#" + mid + "/2 ",
+ commandsManager.processCommand(user, " \t\n #" + mid + "/2 ",
URI.create("http://static.juick.com/settings/facebook.png")).getText());
Message reply = messagesService.getReplies(user, mid).stream().filter(m -> m.getRid() == 3).findFirst()
.orElse(new Message());