From 32b15047b1c004b87b096e4c659ce13d5ed68411 Mon Sep 17 00:00:00 2001 From: Martin Tirion Date: Thu, 19 Dec 2024 14:46:31 +0000 Subject: [PATCH] Fixed mailto reference detection --- .../DocAssembler.Test/IssueTests.cs | 43 ++++++++++++++++++- .../DocAssembler/FileService/Hyperlink.cs | 4 +- 2 files changed, 44 insertions(+), 3 deletions(-) diff --git a/src/DocAssembler/DocAssembler.Test/IssueTests.cs b/src/DocAssembler/DocAssembler.Test/IssueTests.cs index 4f036d9..5e9128a 100644 --- a/src/DocAssembler/DocAssembler.Test/IssueTests.cs +++ b/src/DocAssembler/DocAssembler.Test/IssueTests.cs @@ -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; @@ -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:john@doe.com)".NormalizeContent(); var folder = _fileService.AddFolder($"docs"); _fileService.AddFile(folder, "README.md", string.Empty diff --git a/src/DocAssembler/DocAssembler/FileService/Hyperlink.cs b/src/DocAssembler/DocAssembler/FileService/Hyperlink.cs index 20cbe45..9252e13 100644 --- a/src/DocAssembler/DocAssembler/FileService/Hyperlink.cs +++ b/src/DocAssembler/DocAssembler/FileService/Hyperlink.cs @@ -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[] { '#', '?' };