Skip to content

Commit

Permalink
Merge pull request #93 from Ellerbach/92-fix-docassembler-mailto-ref
Browse files Browse the repository at this point in the history
Fixed mailto reference detection
  • Loading branch information
Ellerbach authored Dec 19, 2024
2 parents f3d7054 + 32b1504 commit 33f17fd
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 3 deletions.
43 changes: 42 additions & 1 deletion src/DocAssembler/DocAssembler.Test/IssueTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using Bogus;
using DocAssembler.Actions;
using DocAssembler.Configuration;
using DocAssembler.FileService;
using DocAssembler.Test.Helpers;
using FluentAssertions;
using Microsoft.Extensions.Logging;
Expand Down Expand Up @@ -38,7 +39,47 @@ public async void Issue_89_refHeaderInSameFile()
string expected =
@"#Documentation Readme
LINK [title](#documentation-readme)";
LINK [title](#documentation-readme)".NormalizeContent();

var folder = _fileService.AddFolder($"docs");
_fileService.AddFile(folder, "README.md", string.Empty
.AddRaw(expected));

// arrange
AssembleConfiguration config = new AssembleConfiguration
{
DestinationFolder = "out",
Content =
[
new Content
{
SourceFolder = "docs",
DestinationFolder = "general",
Files = { "**" },
}
]
};

InventoryAction action = new(_workingFolder, config, _fileService, _logger);

// act
var ret = await action.RunAsync();

// assert
ret.Should().Be(ReturnCode.Normal);
var content = _fileService.ReadAllText(_fileService.Files.Last().Key);
content.Should().Be(expected);
}

[Fact]
public async void Issue_92_refMailTo()
{
_fileService.Files.Clear();

string expected =
@"#Documentation Readme
LINK [John Doe](mailto:[email protected])".NormalizeContent();

var folder = _fileService.AddFolder($"docs");
_fileService.AddFile(folder, "README.md", string.Empty
Expand Down
4 changes: 2 additions & 2 deletions src/DocAssembler/DocAssembler/FileService/Hyperlink.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ public class Hyperlink
{ "http://", HyperlinkType.Webpage },
{ "ftps://", HyperlinkType.Ftp },
{ "ftp://", HyperlinkType.Ftp },
{ "mailto://", HyperlinkType.Mail },
{ "xref://", HyperlinkType.CrossReference },
{ "mailto:", HyperlinkType.Mail },
{ "xref:", HyperlinkType.CrossReference },
};

private static readonly char[] _uriFragmentOrQueryString = new char[] { '#', '?' };
Expand Down

0 comments on commit 33f17fd

Please sign in to comment.