From 1594f453f3cecaf21f4d6a8a2c40b2a93ff1053a Mon Sep 17 00:00:00 2001 From: yushijinhun Date: Fri, 5 Oct 2018 18:31:32 +0800 Subject: [PATCH] Prepend https:// when protocol is not specified (#17) --- .../moe/yushi/authlibinjector/AuthlibInjector.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/main/java/moe/yushi/authlibinjector/AuthlibInjector.java b/src/main/java/moe/yushi/authlibinjector/AuthlibInjector.java index 972e741..456ec65 100644 --- a/src/main/java/moe/yushi/authlibinjector/AuthlibInjector.java +++ b/src/main/java/moe/yushi/authlibinjector/AuthlibInjector.java @@ -99,7 +99,7 @@ public final class AuthlibInjector { String apiRoot = System.getProperty(PROP_API_ROOT); if (apiRoot == null) return empty(); - apiRoot = appendSuffixSlash(apiRoot); + apiRoot = parseInputUrl(apiRoot); Logging.CONFIG.info("API root: " + apiRoot); warnIfHttp(apiRoot); @@ -155,6 +155,16 @@ public final class AuthlibInjector { } } + private static String parseInputUrl(String url) { + String lowercased = url.toLowerCase(); + if (!lowercased.startsWith("http://") && !lowercased.startsWith("https://")) { + url = "https://" + url; + } + + url = appendSuffixSlash(url); + return url; + } + private static ClassTransformer createTransformer(YggdrasilConfiguration config) { ClassTransformer transformer = new ClassTransformer(); transformer.debugSaveClass = "true".equals(System.getProperty(PROP_DUMP_CLASS));