Skip to content

Commit d02075d

Browse files
Prefix client identifiers with 'client:' if not already prefixed (#458)
1 parent ce1c451 commit d02075d

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

src/main/java/com/twilio/type/Client.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,15 @@
44

55
public class Client implements Endpoint {
66

7+
public static final String PREFIX = "client:";
8+
79
private final String client;
810

911
public Client(String client) {
12+
if (!client.toLowerCase().startsWith(PREFIX)) {
13+
client = PREFIX + client;
14+
}
15+
1016
this.client = client;
1117
}
1218

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package com.twilio.type;
2+
3+
import org.junit.Assert;
4+
import org.junit.Test;
5+
6+
public class ClientTest {
7+
8+
@Test
9+
public void testGetEndpoint() {
10+
Assert.assertEquals("client:me", new Client("me").getEndpoint());
11+
Assert.assertEquals("client:YOU", new Client("YOU").getEndpoint());
12+
Assert.assertEquals("CLIENT:HIM", new Client("CLIENT:HIM").getEndpoint());
13+
Assert.assertEquals("cLiEnT:her", new Client("cLiEnT:her").getEndpoint());
14+
}
15+
}

0 commit comments

Comments
 (0)