Prepend https:// when protocol is not specified (#17)

This commit is contained in:
yushijinhun 2018-10-05 18:31:32 +08:00
parent 0b81d69ff8
commit 1594f453f3
No known key found for this signature in database
GPG key ID: 5BC167F73EA558E4

View file

@ -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));