From cecd8cc281fd32f3542b99f2438d3bd71f6339c4 Mon Sep 17 00:00:00 2001 From: Nages <79894501+nageslan@users.noreply.github.com> Date: Thu, 8 Jun 2023 20:51:39 +0800 Subject: [PATCH] Update UrlSource.java fix url error. --- .../launcher/download/support/UrlSource.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/com/aof/mcinabox/launcher/download/support/UrlSource.java b/app/src/main/java/com/aof/mcinabox/launcher/download/support/UrlSource.java index 1411aad6..931ed2af 100644 --- a/app/src/main/java/com/aof/mcinabox/launcher/download/support/UrlSource.java +++ b/app/src/main/java/com/aof/mcinabox/launcher/download/support/UrlSource.java @@ -79,13 +79,23 @@ public String getSourceUrl(String sourceName, String type) { } public String getFileUrl(String originUrl, String sourceName, String type) { + if ("origin".equals(sourceName)){ + return originUrl; + } String convertedUrl; StringBuilder Str1 = new StringBuilder(); String Str2 = getSourceUrl(SettingJson.DOWNLOAD_SOURCE_OFFICIAL, type); for (int i = Str2.length(); i < originUrl.length(); i++) { Str1.append(originUrl.charAt(i)); } - convertedUrl = getSourceUrl(sourceName, type) + Str1; + // 修复者 nageslan: 修复了下载游戏版本直接报错的问题, 因为下载的时候SourceUrl 没有戴 "/" 符号, 而且Str1也没有"/"符号前缀,导致直接修改了域名 + String url = Str1.toString(); + if (!"".equals(url)){ + if (!url.startsWith("/")){ + url = "/" +url.substring(1); + } + } + convertedUrl = getSourceUrl(sourceName, type) + url; return convertedUrl; } }