Skip to content

Commit

Permalink
don't modify invalid file link
Browse files Browse the repository at this point in the history
  • Loading branch information
vwxyzh committed May 4, 2016
1 parent 5668ab6 commit e3ab8f7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
11 changes: 7 additions & 4 deletions src/Microsoft.DocAsCode.Build.Engine/HostService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -225,11 +225,14 @@ where string.Equals(attr.Name, "src", StringComparison.OrdinalIgnoreCase) ||
}
var path = (RelativePath)ft.File + (RelativePath)linkFile;
var file = path.GetPathFromWorkingFolder();
link.Value = file;
if (!string.IsNullOrEmpty(anchor) &&
string.Equals(link.Name, "href", StringComparison.OrdinalIgnoreCase))
if (SourceFiles.ContainsKey(file))
{
pair.Node.SetAttributeValue("anchor", anchor);
link.Value = file;
if (!string.IsNullOrEmpty(anchor) &&
string.Equals(link.Name, "href", StringComparison.OrdinalIgnoreCase))
{
pair.Node.SetAttributeValue("anchor", anchor);
}
}
linkToFiles.Add(HttpUtility.UrlDecode(file));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ private static void UpdateHref(HtmlAgilityPack.HtmlNode link, string attribute,
}
else
{
// Logger.LogWarning($"File {path} is not found in {relativePath}.");
Logger.LogWarning($"File {path} is not found in {relativePath}.");
// TODO: what to do if file path not exists?
// CURRENT: fallback to the original one
link.SetAttributeValue(attribute, path);
Expand Down

0 comments on commit e3ab8f7

Please sign in to comment.