fixed "&" issues.
This commit is contained in:
parent
018110cb55
commit
6671872469
|
|
@ -107,4 +107,62 @@ public static class ArrayHelper
|
|||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
//dotnetperls
|
||||
static class SubstringExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Get string value between [first] a and [last] b.
|
||||
/// </summary>
|
||||
public static string Between(this string value, string a, string b)
|
||||
{
|
||||
int posA = value.IndexOf(a);
|
||||
int posB = value.LastIndexOf(b);
|
||||
if (posA == -1)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
if (posB == -1)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
int adjustedPosA = posA + a.Length;
|
||||
if (adjustedPosA >= posB)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
return value.Substring(adjustedPosA, posB - adjustedPosA);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get string value after [first] a.
|
||||
/// </summary>
|
||||
public static string Before(this string value, string a)
|
||||
{
|
||||
int posA = value.IndexOf(a);
|
||||
if (posA == -1)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
return value.Substring(0, posA);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get string value after [last] a.
|
||||
/// </summary>
|
||||
public static string After(this string value, string a)
|
||||
{
|
||||
int posA = value.LastIndexOf(a);
|
||||
if (posA == -1)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
int adjustedPosA = posA + a.Length;
|
||||
if (adjustedPosA >= value.Length)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
return value.Substring(adjustedPosA);
|
||||
}
|
||||
}
|
||||
|
|
@ -64,11 +64,15 @@ public static class RobloxXMLLocalizer
|
|||
{
|
||||
//do whatever with your value
|
||||
string url = item3.Value;
|
||||
DownloadFilesFromNode(url, outputPath, fileext);
|
||||
if (url.Contains('='))
|
||||
string urlFixed = url.Replace("&", "&").Replace("amp;", "&");
|
||||
//MessageBox.Show(urlFixed, "Novetus Asset Localizer", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
string peram = "id=";
|
||||
|
||||
if (urlFixed.Contains(peram))
|
||||
{
|
||||
string[] substrings = url.Split('=');
|
||||
item3.Value = inGameDir + substrings[1] + fileext;
|
||||
string IDVal = urlFixed.After(peram);
|
||||
DownloadFilesFromNode(urlFixed, outputPath, fileext, IDVal);
|
||||
item3.Value = inGameDir + IDVal + fileext;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -86,24 +90,19 @@ public static class RobloxXMLLocalizer
|
|||
}
|
||||
}
|
||||
|
||||
private static void DownloadFilesFromNode(string url, string path, string fileext)
|
||||
private static void DownloadFilesFromNode(string url, string path, string fileext, string id)
|
||||
{
|
||||
if (url.Contains('='))
|
||||
if (!string.IsNullOrWhiteSpace(id))
|
||||
{
|
||||
string[] substrings = url.Split('=');
|
||||
Downloader download = new Downloader(url, id);
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(substrings[1]))
|
||||
try
|
||||
{
|
||||
Downloader download = new Downloader(url, substrings[1]);
|
||||
|
||||
try
|
||||
{
|
||||
download.InitDownload(path, fileext);
|
||||
}
|
||||
catch (Exception ex) when (!Env.Debugging)
|
||||
{
|
||||
MessageBox.Show("The download has experienced an error: " + ex.Message, "Novetus Asset Localizer", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
}
|
||||
download.InitDownload(path, fileext);
|
||||
}
|
||||
catch (Exception ex) when (!Env.Debugging)
|
||||
{
|
||||
MessageBox.Show("The download has experienced an error: " + ex.Message, "Novetus Asset Localizer", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue