Don't hardcode the host for the socket to the main Gemini project page.  Determine it dynamically.
1 files changed, 10 insertions(+), 3 deletions(-)

M src/main/java/com/ajtjp/geminiclient/GeminiClient.java
M src/main/java/com/ajtjp/geminiclient/GeminiClient.java +10 -3
@@ 31,9 31,16 @@ public class GeminiClient {
         GeminiDocument doc = new GeminiDocument(url);
         
 //        String hardcodedURL = "rawtext.club";
-        String hardcodedURL = "gemini.circumlunar.space";
-        Socket s = basicSocketFactory.createSocket(hardcodedURL, port);
-        s = sslSocketFactory.createSocket(s, hardcodedURL, port, true);
+
+        int colonSlashSlashIndex = url.indexOf("://");
+        int endOfHost = url.indexOf("/", colonSlashSlashIndex + 3);
+        if (endOfHost == -1) {
+            endOfHost = url.length();
+        }
+        String host = url.substring(colonSlashSlashIndex + 3, endOfHost);
+
+        Socket s = basicSocketFactory.createSocket(host, port);
+        s = sslSocketFactory.createSocket(s, host, port, true);
         
         OutputStream os = s.getOutputStream();
         os.write((url + "\r\n").getBytes());