Skip to content

Commit 782566b

Browse files
committed
Extract to a constant
1 parent c21bcb9 commit 782566b

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

core/src/main/java/com/auth0/authentication/api/internal/ApplicationInfoRequest.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@
4444

4545
class ApplicationInfoRequest extends BaseRequest<Application> implements Callback {
4646

47+
private static final String JSONP_PREFIX = "Auth0.setClient(";
48+
4749
public ApplicationInfoRequest(OkHttpClient client, HttpUrl url, ObjectMapper mapper) {
4850
super(url, client, mapper.reader(Application.class), mapper.reader(new TypeReference<Map<String, Object>>() {}), null);
4951
}
@@ -96,10 +98,11 @@ public Application execute() throws Auth0Exception {
9698
private Application parseJSONP(Response response) {
9799
try {
98100
String json = response.body().string();
99-
if (json.length() < 16) {
101+
final int length = JSONP_PREFIX.length();
102+
if (json.length() < length) {
100103
throw new JSONException("Invalid App Info JSONP");
101104
}
102-
json = json.substring("Auth0.setClient(".length()); // replaces tokenizer.skipPast("Auth0.setClient(") because official (not android's) org.json does not have the method
105+
json = json.substring(length);
103106
JSONTokener tokenizer = new JSONTokener(json);
104107
if (!tokenizer.more()) {
105108
throw tokenizer.syntaxError("Invalid App Info JSONP");

0 commit comments

Comments
 (0)