Convert idn domain

pull/2917/head
2dust 2022-12-13 20:02:45 +08:00
parent 529b6613e9
commit b48037b757
2 changed files with 25 additions and 0 deletions

View File

@ -212,6 +212,7 @@ namespace v2rayN.Handler
_updateFunc(false, $"{hashCode}{args.GetException().Message}"); _updateFunc(false, $"{hashCode}{args.GetException().Message}");
}; };
url = Utils.GetPunycode(url);
_updateFunc(false, $"{hashCode}{ResUI.MsgStartGettingSubscriptions}"); _updateFunc(false, $"{hashCode}{ResUI.MsgStartGettingSubscriptions}");
var result = await downloadHandle.DownloadStringAsync(url, blProxy, userAgent); var result = await downloadHandle.DownloadStringAsync(url, blProxy, userAgent);
if (blProxy && Utils.IsNullOrEmpty(result)) if (blProxy && Utils.IsNullOrEmpty(result))

View File

@ -413,6 +413,30 @@ namespace v2rayN
return sb.ToString(); return sb.ToString();
} }
public static string GetPunycode(string url)
{
if (string.IsNullOrWhiteSpace(url))
{
return url;
}
try
{
Uri uri = new Uri(url);
if (uri.Host == uri.IdnHost)
{
return url;
}
else
{
return url.Replace(uri.Host, uri.IdnHost);
}
}
catch
{
return url;
}
}
#endregion #endregion