Skip to content
This repository was archived by the owner on Jun 21, 2019. It is now read-only.

Commit b52c630

Browse files
author
Maxime Dor
committed
Correctly handle Matrix IDs with port in them
1 parent e46acb5 commit b52c630

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

src/main/java/io/kamax/matrix/MatrixID.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525

2626
public class MatrixID implements _MatrixID {
2727

28-
private static final Pattern matrixIdLaxPattern = Pattern.compile("@(.*):(.+)");
28+
private static final Pattern matrixIdLaxPattern = Pattern.compile("@(.*?):(.+)");
2929
private static final Pattern matrixIdStrictPattern = Pattern.compile("@([0-9a-z-.=_]+):(.+)");
3030

3131
private String id;

src/test/java/io/kamax/matrix/MatrixIDTest.java

+6
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ public class MatrixIDTest {
2929
private static String validMxId1 = "@john.doe:example.org";
3030
private static String validMxId2 = "@john.doe:example.com";
3131
private static String validMxId3 = "@JoHn.dOe:ExamPLE.ORG";
32+
private static String validMxid4 = "@john:example.org:8449";
33+
private static String validMxid5 = "@john:::1:8449";
3234

3335
private static String invalidMxId1 = "john.doe:example.org";
3436
private static String invalidMxId2 = "@john.doeexample.org";
@@ -40,9 +42,13 @@ public class MatrixIDTest {
4042
public void validMatrixIDs() {
4143
_MatrixID mxId1 = new MatrixID(validMxId1);
4244
_MatrixID mxId3 = new MatrixID(validMxId3);
45+
_MatrixID mxId4 = new MatrixID(validMxid4);
46+
_MatrixID mxId5 = new MatrixID(validMxid5);
4347
assertTrue(validMxId1.contentEquals(mxId1.getId()));
4448
assertTrue("john.doe".contentEquals(mxId1.getLocalPart()));
4549
assertTrue("example.org".contentEquals(mxId1.getDomain()));
50+
assertTrue("example.org:8449".contentEquals(mxId4.getDomain()));
51+
assertTrue("::1:8449".contentEquals(mxId5.getDomain()));
4652
}
4753

4854
@Test

0 commit comments

Comments
 (0)