Arsnael commented on a change in pull request #531:
URL: https://github.com/apache/james-project/pull/531#discussion_r665001000
##########
File path: core/src/main/java/org/apache/james/core/Username.java
##########
@@ -40,14 +37,16 @@ public static Username of(String username) {
Preconditions.checkArgument(username.length() <=
MAXIMUM_MAIL_ADDRESS_LENGTH,
"username length should not be longer than %s characters",
MAXIMUM_MAIL_ADDRESS_LENGTH);
- List<String> parts =
ImmutableList.copyOf(Splitter.on('@').split(username));
- switch (parts.size()) {
- case 1:
- return fromLocalPartWithoutDomain(username);
- case 2:
- return fromLocalPartWithDomain(parts.get(0), parts.get(1));
+ int atPosition = username.indexOf('@');
+ if (atPosition < 0) {
+ return fromLocalPartWithoutDomain(username);
}
- throw new IllegalArgumentException("The username should not contain
multiple domain delimiter. Value: " + username);
+ String userPart = username.substring(0, atPosition);
+ String domainPart = username.substring(atPosition + 1);
+ if (domainPart.indexOf('@') > 0) {
Review comment:
`>=` ? If you have an extra `@` at the index 0 you miss it?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]