Link rendering: Add support for UrlMode parameter in HtmlLocalLinkParser#20200
Merged
AndyButland merged 2 commits intov13/devfrom Sep 20, 2025
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR adds support for a UrlMode parameter to the HtmlLocalLinkParser class to enable control over URL generation modes (relative vs absolute). This enhancement is needed to fix an issue where Umbraco Forms email templates require absolute URLs for proper rendering.
- Adds new overloads for
EnsureInternalLinksmethods that accept aUrlModeparameter - Updates internal method calls to pass the URL mode through to the URL providers
- Maintains backward compatibility by keeping existing method signatures
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/Umbraco.Core/Templates/HtmlLocalLinkParser.cs | Adds new overloads with UrlMode parameter and updates internal URL generation calls |
| tests/Umbraco.Tests.UnitTests/Umbraco.Core/Templates/HtmlLocalLinkParserTests.cs | Adds comprehensive unit tests covering various URL modes for both content and media links |
tests/Umbraco.Tests.UnitTests/Umbraco.Core/Templates/HtmlLocalLinkParserTests.cs
Show resolved
Hide resolved
tests/Umbraco.Tests.UnitTests/Umbraco.Core/Templates/HtmlLocalLinkParserTests.cs
Show resolved
Hide resolved
tests/Umbraco.Tests.UnitTests/Umbraco.Core/Templates/HtmlLocalLinkParserTests.cs
Show resolved
Hide resolved
tests/Umbraco.Tests.UnitTests/Umbraco.Core/Templates/HtmlLocalLinkParserTests.cs
Show resolved
Hide resolved
ronaldbarendse
approved these changes
Sep 19, 2025
AndyButland
approved these changes
Sep 20, 2025
Contributor
AndyButland
left a comment
There was a problem hiding this comment.
Thanks @rickbutterfield - all looks to work as expected. I've verified also via:
@inject HtmlLocalLinkParser LocalLinkParser;
<div>@LocalLinkParser.EnsureInternalLinks("a href=\"{localLink:4148}\"")</div>
<div>@LocalLinkParser.EnsureInternalLinks("a href=\"{localLink:4148}\"", UrlMode.Absolute)</div>
And see the expected results.
UrlMode parameter in HtmlLocalLinkParserUrlMode parameter in HtmlLocalLinkParser
AndyButland
added a commit
that referenced
this pull request
Sep 20, 2025
kjac
added a commit
that referenced
this pull request
Sep 22, 2025
…Parser` (port to 16) (#20207) * Add support for UrlMode parameter in HtmlLocalLinkParser (port of #20200 from 13 to 16). * Apply suggestions from code review Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: Kenn Jacobsen <kja@umbraco.dk>
This was referenced Dec 9, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Prerequisites
Related issue: umbraco/Umbraco.Forms.Issues#1414
Description
This is the first part of a fix for the issue linked above.
This PR adds a new overload for
EnsureInternalLinksin theHtmlLocalLinkParserthat accepts aUrlModeparameter. The aim of this is to allow the Umbraco Forms "Send email with template" workflow to correctly renderlocalLinks in the Header/Body/Footer fields as absolute URLs rather than relative ones.The changes are completely backwards compatible and non-breaking, with unit tests added too. The fix should be able to be cherry picked to v16.