Skip to content

Commit fd90446

Browse files
committed
feat: Guess if the API endpoint is raw or not
1 parent 8673ab5 commit fd90446

3 files changed

Lines changed: 16 additions & 0 deletions

File tree

src/main/java/com/godiddy/cli/commands/config/ConfigEndpointCommand.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ public Integer call() throws Exception {
5555
}
5656
CLIConfig.setEndpoint(endpoint);
5757
if (this.endpointRaw == null) {
58+
CLIConfig.setEndpointRaw(null);
5859
System.out.println("Endpoint successfully set: " + endpoint);
5960
} else {
6061
Boolean endpointRaw = this.endpointRaw;

src/main/java/com/godiddy/cli/config/Api.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ public void onComplete() { }
104104

105105
private static final Consumer<HttpRequest.Builder> requestInterceptor = builder -> {
106106
Boolean endpointRaw = Endpoint.getEndpointRaw();
107+
if (endpointRaw == null) endpointRaw = Endpoint.guessEndpointRaw();
107108
if (Boolean.TRUE.equals(endpointRaw)) {
108109
String endpointWithSlash = Endpoint.getEndpoint();
109110
if (! endpointWithSlash.endsWith("/")) endpointWithSlash += "/";

src/main/java/com/godiddy/cli/config/Endpoint.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,18 @@ public static Boolean getEndpointRaw() {
4545
Boolean endpointRaw = Objects.requireNonNullElse(CLIConfig.getEndpointRaw(), DEFAULT_ENDPOINTRAW);
4646
return endpointRaw;
4747
}
48+
49+
public static Boolean guessEndpointRaw() {
50+
String endpoint = getEndpoint();
51+
if (endpoint == null) return null;
52+
if (endpoint.contains("universal-resolver")) return Boolean.TRUE;
53+
if (endpoint.contains("universal-registrar")) return Boolean.TRUE;
54+
if (endpoint.contains("uni-resolver")) return Boolean.TRUE;
55+
if (endpoint.contains("uni-registrar")) return Boolean.TRUE;
56+
if (endpoint.contains("uniresolver.io")) return Boolean.TRUE;
57+
if (endpoint.contains("uniregistrar.io")) return Boolean.TRUE;
58+
if (endpoint.contains(":8080")) return Boolean.TRUE;
59+
if (endpoint.contains(":9080")) return Boolean.TRUE;
60+
return Boolean.FALSE;
61+
}
4862
}

0 commit comments

Comments
 (0)