fixed "&" issues.

This commit is contained in:
Bitl 2019-11-13 18:20:50 -07:00
parent 018110cb55
commit 6671872469
2 changed files with 75 additions and 18 deletions

View File

@ -108,3 +108,61 @@ public static class ArrayHelper
return result; 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);
}
}

View File

@ -64,11 +64,15 @@ public static class RobloxXMLLocalizer
{ {
//do whatever with your value //do whatever with your value
string url = item3.Value; string url = item3.Value;
DownloadFilesFromNode(url, outputPath, fileext); string urlFixed = url.Replace("&amp;", "&").Replace("amp;", "&");
if (url.Contains('=')) //MessageBox.Show(urlFixed, "Novetus Asset Localizer", MessageBoxButtons.OK, MessageBoxIcon.Information);
string peram = "id=";
if (urlFixed.Contains(peram))
{ {
string[] substrings = url.Split('='); string IDVal = urlFixed.After(peram);
item3.Value = inGameDir + substrings[1] + fileext; DownloadFilesFromNode(urlFixed, outputPath, fileext, IDVal);
item3.Value = inGameDir + IDVal + fileext;
} }
} }
} }
@ -86,15 +90,11 @@ 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]))
{
Downloader download = new Downloader(url, substrings[1]);
try try
{ {
@ -106,7 +106,6 @@ public static class RobloxXMLLocalizer
} }
} }
} }
}
private static string RemoveInvalidXmlChars(string content) private static string RemoveInvalidXmlChars(string content)
{ {