Skip to content

APIDomain with new domain name in Android 4.x.x #49

@djay789

Description

@djay789

Some domain names can contain something like '.abcdef" (and more...) (sample : ws.mobile.mycompany instead of ws.mobile.mycompany.com)

But in Android 4.x.x, the setApiDomain causes a freeze with such domain name.

public Builder setApiDomain(String domain){
     if (domain==null) mApiDomain = "10.0.2.2";
     if(Patterns.IP_ADDRESS.matcher(domain).matches()||
         Patterns.DOMAIN_NAME.matcher(domain).matches()){
         mApiDomain = domain;
     } else {
         throw new RuntimeException("Invalid host name: "+domain+". Hint: don't specify protocol (eg. http) or path");
    }
    return this;
}

The issue is Patterns.DOMAIN_NAME.matcher(domain).matches() : the Patterns.DOMAIN_NAME is more limited in Android 4.x.x
Here are the source code from Android:

I tried to use a new method to force the API Domain without check, it works fine:

public Builder setApiDomainWithoutCheck(String domain){
    mApiDomain = domain;
    return this;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions