Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9207afdc authored by Philip Whitehouse's avatar Philip Whitehouse
Browse files

Address: Handle getHostname when mAddress is null

parent 19b7d449
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -78,6 +78,10 @@ public class Address implements Serializable {
    }

    public String getHostname() {
        if (mAddress == null) {
            return null;
        }

        int hostIdx = mAddress.lastIndexOf("@");

        if (hostIdx == -1) {
+9 −0
Original line number Diff line number Diff line
@@ -148,4 +148,13 @@ public class AddressTest {

        assertFalse(result);
    }

    @Test
    public void getHostname_withoutAddress_isNull() throws Exception {
        Address address = Address.parse("Alice")[0];

        String result = address.getHostname();

        assertNull(result);
    }
}