Detect invalid slashes in markdown links.

[CL 32790915 by ben marsh in ue5-main branch]
This commit is contained in:
ben marsh
2024-04-08 09:23:20 -04:00
parent 515a8b0bc2
commit e6b26cf1a2

View File

@@ -96,18 +96,21 @@ namespace AutomationTool.Tasks
string link = match.Groups[2].Value;
if (!Regex.IsMatch(link, "^(?:[a-z]+:/)?/"))
{
int hashIdx = link.IndexOf('#');
if (hashIdx == -1)
if (!link.Contains('\\'))
{
link = FileReference.Combine(file.Directory, link).FullName;
}
else if (hashIdx == 0)
{
link = $"{file}{link[hashIdx..]}";
}
else
{
link = $"{FileReference.Combine(file.Directory, link[0..hashIdx])}{link[hashIdx..]}";
int hashIdx = link.IndexOf('#');
if (hashIdx == -1)
{
link = FileReference.Combine(file.Directory, link).FullName;
}
else if (hashIdx == 0)
{
link = $"{file}{link[hashIdx..]}";
}
else
{
link = $"{FileReference.Combine(file.Directory, link[0..hashIdx])}{link[hashIdx..]}";
}
}
bool validLink;