pull/533/head
Alper Ebicoglu 7 years ago
parent e4e440bc2d
commit a899914ab1

@ -32,7 +32,7 @@ namespace Volo.Docs.Formatting
var normalized = Regex.Replace(content, MarkdownLinkRegExp, delegate (Match match) var normalized = Regex.Replace(content, MarkdownLinkRegExp, delegate (Match match)
{ {
var displayText = match.Groups[1].Value; var displayText = match.Groups[1].Value;
var documentName = RemoveFileExtensionIfLocalUrl(match.Groups[2].Value); var documentName = RemoveFileExtension(match.Groups[2].Value);
var documentLocalDirectoryNormalized = documentLocalDirectory.TrimStart('/').TrimEnd('/'); var documentLocalDirectoryNormalized = documentLocalDirectory.TrimStart('/').TrimEnd('/');
if (!string.IsNullOrWhiteSpace(documentLocalDirectoryNormalized)) if (!string.IsNullOrWhiteSpace(documentLocalDirectoryNormalized))
{ {
@ -43,22 +43,28 @@ namespace Volo.Docs.Formatting
}); });
normalized = Regex.Replace(normalized, AnchorLinkRegExp, delegate (Match match) normalized = Regex.Replace(normalized, AnchorLinkRegExp, delegate (Match match)
{ {
var displayText = match.Groups[2].Value; var link = match.Groups[1].Value;
var documentName = RemoveFileExtensionIfLocalUrl(match.Groups[1].Value); if (IsRemoteUrl(link))
var documentLocalDirectoryNormalized = documentLocalDirectory.TrimStart('/').TrimEnd('/'); {
if (!string.IsNullOrWhiteSpace(documentLocalDirectoryNormalized)) return match.Value;
{ }
documentLocalDirectoryNormalized = "/" + documentLocalDirectoryNormalized;
} var displayText = match.Groups[2].Value;
var documentName = RemoveFileExtension(link);
return string.Format(NewLinkFormat, displayText, projectShortName, version, documentLocalDirectoryNormalized, documentName); var documentLocalDirectoryNormalized = documentLocalDirectory.TrimStart('/').TrimEnd('/');
}); if (!string.IsNullOrWhiteSpace(documentLocalDirectoryNormalized))
{
documentLocalDirectoryNormalized = "/" + documentLocalDirectoryNormalized;
}
return string.Format(NewLinkFormat, displayText, projectShortName, version, documentLocalDirectoryNormalized, documentName);
});
return normalized; return normalized;
} }
private static string RemoveFileExtensionIfLocalUrl(string documentName) private static string RemoveFileExtension(string documentName)
{ {
if (documentName == null) if (documentName == null)
{ {
@ -75,11 +81,6 @@ namespace Volo.Docs.Formatting
return documentName; return documentName;
} }
if (IsRemoteUrl(documentName))
{
return documentName;
}
return documentName.Left(documentName.Length - Type.Length - 1); return documentName.Left(documentName.Length - Type.Length - 1);
} }

Loading…
Cancel
Save