Removed Type attribute from parsed local links (#16780)

* Removed type attribute from processed local links

improved code readabilty by using multi return type to private class

* Removed type attribute from processed locallinks in delivery api

* Removed type attribute from expected output regarding locallink parsing

* Cleanup

* Fixed spacing bug

* Added 2 more edge test cases

---------

Co-authored-by: Elitsa <elm@umbraco.dk>
This commit is contained in:
Sven Geusens
2024-07-23 10:25:54 +02:00
committed by GitHub
parent 94ee50c819
commit 9e0fb54ea5
4 changed files with 67 additions and 29 deletions

View File

@@ -1,7 +1,6 @@
// Copyright (c) Umbraco.
// See LICENSE for more details.
using System.Linq;
using Microsoft.Extensions.Options;
using Moq;
using NUnit.Framework;
@@ -13,7 +12,6 @@ using Umbraco.Cms.Core.Routing;
using Umbraco.Cms.Core.Templates;
using Umbraco.Cms.Tests.Common;
using Umbraco.Cms.Tests.UnitTests.TestHelpers.Objects;
using Umbraco.Extensions;
namespace Umbraco.Cms.Tests.UnitTests.Umbraco.Core.Templates;
@@ -111,10 +109,16 @@ public class HtmlLocalLinkParserTests
// current
[TestCase(
"<a type=\"document\" href=\"/{localLink:9931BDE0-AAC3-4BAB-B838-909A7B47570E}\" title=\"world\">world</a>",
"<a type=\"document\" href=\"/my-test-url\" title=\"world\">world</a>")]
"<a href=\"/my-test-url\" title=\"world\">world</a>")]
[TestCase(
"<a type=\"media\" href=\"/{localLink:9931BDE0-AAC3-4BAB-B838-909A7B47570E}\" title=\"world\">world</a>",
"<a type=\"media\" href=\"/media/1001/my-image.jpg\" title=\"world\">world</a>")]
"<a href=\"/media/1001/my-image.jpg\" title=\"world\">world</a>")]
[TestCase(
"<a href=\"/{localLink:9931BDE0-AAC3-4BAB-B838-909A7B47570E}\"type=\"document\" title=\"world\">world</a>",
"<a href=\"/my-test-url\" title=\"world\">world</a>")]
[TestCase(
"<a href=\"/{localLink:9931BDE0-AAC3-4BAB-B838-909A7B47570E}\" title=\"world\"type=\"media\">world</a>",
"<a href=\"/media/1001/my-image.jpg\" title=\"world\">world</a>")]
// legacy
[TestCase(
"hello href=\"{localLink:1234}\" world ",

View File

@@ -72,8 +72,8 @@ public class ApiRichTextMarkupParserTests
<p>and to the <a type=""document"" href=""/{localLink:cc143afe-4cbf-46e5-b399-c9f451384373}"" title=""other page"">other page</a></p>";
var expectedOutput =
@"<p>Rich text outside of the blocks with a link to <a type=""document"" href=""/self/"" title=""itself"" data-start-item-path=""self"" data-start-item-id=""eed5fc6b-96fd-45a5-a0f1-b1adfb483c2f"">itself</a><br><br></p>
<p>and to the <a type=""document"" href=""/other/"" title=""other page"" data-start-item-path=""other"" data-start-item-id=""cc143afe-4cbf-46e5-b399-c9f451384373"">other page</a></p>";
@"<p>Rich text outside of the blocks with a link to <a href=""/self/"" title=""itself"" data-start-item-path=""self"" data-start-item-id=""eed5fc6b-96fd-45a5-a0f1-b1adfb483c2f"">itself</a><br><br></p>
<p>and to the <a href=""/other/"" title=""other page"" data-start-item-path=""other"" data-start-item-id=""cc143afe-4cbf-46e5-b399-c9f451384373"">other page</a></p>";
var parsedHtml = parser.Parse(html);