Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed mailto reference detection #93

Merged
merged 1 commit into from
Dec 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading