Skip to content

Link rendering: Add support for UrlMode parameter in HtmlLocalLinkParser#20200

Merged
AndyButland merged 2 commits intov13/devfrom
v13/feature/html-local-link-parser-url-mode
Sep 20, 2025
Merged

Link rendering: Add support for UrlMode parameter in HtmlLocalLinkParser#20200
AndyButland merged 2 commits intov13/devfrom
v13/feature/html-local-link-parser-url-mode

Conversation

@rickbutterfield
Copy link
Contributor

@rickbutterfield rickbutterfield commented Sep 19, 2025

Prerequisites

  • I have added steps to test this contribution in the description below

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 EnsureInternalLinks in the HtmlLocalLinkParser that accepts a UrlMode parameter. The aim of this is to allow the Umbraco Forms "Send email with template" workflow to correctly render localLinks 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.

Copilot AI review requested due to automatic review settings September 19, 2025 12:37
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 EnsureInternalLinks methods that accept a UrlMode parameter
  • 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

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

@rickbutterfield rickbutterfield marked this pull request as ready for review September 19, 2025 13:50
Copy link
Contributor

@AndyButland AndyButland left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@AndyButland AndyButland merged commit 27e3184 into v13/dev Sep 20, 2025
18 of 19 checks passed
@AndyButland AndyButland deleted the v13/feature/html-local-link-parser-url-mode branch September 20, 2025 10:48
@AndyButland AndyButland changed the title Add support for UrlMode parameter in HtmlLocalLinkParser Link rendering: Add support for UrlMode parameter in HtmlLocalLinkParser Sep 20, 2025
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>
@nielslyngsoe nielslyngsoe removed the .NET Pull requests that update .NET code label Oct 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants