Skip to content

Commit 7f8ea0a

Browse files
committed
parse TopLevelDomains correctly.
put out of the loop the check for adding dots to the domain. fixes #21.
1 parent 18a6395 commit 7f8ea0a

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

cSploit/src/main/java/org/csploit/android/net/http/RequestParser.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -300,15 +300,17 @@ public static String getBaseDomain(String hostname){
300300
tld_parts = tld.split("\\.");
301301
int itld = tld_parts.length,
302302
ihost = host_parts.length,
303-
i = 0,
304-
stop = ihost - 1;
303+
i = 0;
304+
305+
if ((ihost - itld) == 0)
306+
return hostname;
305307

306308
domain = "";
307-
for(i = ihost - itld; i <= stop; i++){
308-
domain += host_parts[i] + (i == stop ? "" : ".");
309+
for(i = ihost - itld - 1; i < ihost; i++){
310+
domain += host_parts[i] + ".";
309311
}
310312

311-
return domain;
313+
return domain.substring(0, domain.length() - 1);
312314
}
313315
}
314316

0 commit comments

Comments
 (0)