Skip to content

Commit

Permalink
Fixed some broken links
Browse files Browse the repository at this point in the history
  • Loading branch information
deejaygraham committed Jan 18, 2023
1 parent aaa3090 commit c7193bd
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 6 deletions.
12 changes: 12 additions & 0 deletions src/Core/ExtensionMethods/StringExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,18 @@ public static string HtmlSafeTypeName(this string fullyQualifiedName)
.Replace(XmlLessThan, HtmlLessThan)
.Replace(XmlGreaterThan, HtmlGreaterThan);
}

public static string PathSafeTypeName(this string fullyQualifiedName)
{
const string XmlLessThan = "<";
const string XmlGreaterThan = ">";
const string Underscore = "_";

return fullyQualifiedName
.Replace(XmlLessThan, Underscore)
.Replace(XmlGreaterThan, Underscore)
.Replace(',', '.');
}
}

}
6 changes: 3 additions & 3 deletions src/Core/Reporting/FileMapBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public FileMapBuilder With(IDocumentLink link)
Debug.Assert(this.map != null, "Map not created");
Debug.Assert(this.project != null, "Project not set");

string pagePath = this.project.Settings.SuggestPath(link.LinkUrl.HtmlSafeTypeName(), this.format.Extension);
string pagePath = this.project.Settings.SuggestPath(link.LinkUrl.PathSafeTypeName(), this.format.Extension);
map.Add(link.Identifier, new PhysicalFile(pagePath));

return this;
Expand Down Expand Up @@ -81,7 +81,7 @@ public FileMapBuilder With(IdentifiedChangeCollection change)
Debug.Assert(this.map != null, "Map not created");
Debug.Assert(this.project != null, "Project not set");

string parentPath = project.Settings.SuggestPath(change.Name.HtmlSafeTypeName(), format.Extension);
string parentPath = project.Settings.SuggestPath(change.Name.PathSafeTypeName(), format.Extension);
map.Add(change.Identifier, new PhysicalFile(parentPath));

foreach (var c in change.Changes)
Expand All @@ -94,7 +94,7 @@ public FileMapBuilder With(IdentifiedChangeCollection change)

if (link != null)
{
string pagePath = project.Settings.SuggestPath(link.LinkUrl.HtmlSafeTypeName(), format.Extension);
string pagePath = project.Settings.SuggestPath(link.LinkUrl.PathSafeTypeName(), format.Extension);
map.Add(link.Identifier, new PhysicalFile(pagePath));
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/Core/Reporting/ReportingWorkflow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public void RunReports(Project project, IReportingRepository reportWriters, Anal
// write in reverse order...so that files should exist when we write a link..
foreach (var typeChange in results.TypeLevelChanges)
{
IReportOutput typeOutput = new FileOutput(Path.Combine(project.Settings.SubPath, typeChange.Name.HtmlSafeTypeName() + format.Extension));
IReportOutput typeOutput = new FileOutput(Path.Combine(project.Settings.SubPath, typeChange.Name.PathSafeTypeName() + format.Extension));

progressIndicator.Report(new Progress("Generating report for " + typeChange.Name));

Expand Down Expand Up @@ -128,7 +128,7 @@ public void RunReports(Project project, IReportingRepository reportWriters, Anal
{
Id = results.BreakingChanges.Identifier,
Title = results.BreakingChanges.Name,
Link = Path.Combine(project.Settings.SubPath, results.BreakingChanges.Name + format.Extension),
Link = Path.Combine(project.Settings.SubPath, results.BreakingChanges.Name.Replace(" ", "") + format.Extension),
Indent = siteMap.Indent + 1
});

Expand All @@ -155,7 +155,7 @@ public void RunReports(Project project, IReportingRepository reportWriters, Anal
{
try
{
string fileName = typeChange.Name.Replace('<', '_').Replace('>', '_').Replace(',', '.');
string fileName = typeChange.Name.PathSafeTypeName();

string link = Path.Combine(project.Settings.SubPath, fileName + format.Extension);

Expand Down

0 comments on commit c7193bd

Please sign in to comment.