Skip to content

Link rendering: Add support for UrlMode parameter in HtmlLocalLinkParser (port to 16)#20207

Merged
kjac merged 3 commits intomainfrom
v16/improvement/html-local-link-parser-url-mode
Sep 22, 2025
Merged

Link rendering: Add support for UrlMode parameter in HtmlLocalLinkParser (port to 16)#20207
kjac merged 3 commits intomainfrom
v16/improvement/html-local-link-parser-url-mode

Conversation

@AndyButland
Copy link
Contributor

@AndyButland AndyButland commented Sep 20, 2025

Forward port of #20200 that required a bit more than just a cherry-pick.

In doing so I noticed we had a method that takes a preview parameter that was never used, as the method just delegated to the overload without that parameter. So I've obsoleted that and amended each of the callers.

Unit tests should verify the changes but a manual test can also be done in a view with e.g:

@inject HtmlLocalLinkParser LocalLinkParser;
<div>@LocalLinkParser.EnsureInternalLinks("a href=\"{localLink:4148}\"")</div>
<div>@LocalLinkParser.EnsureInternalLinks("a href=\"{localLink:4148}\"", UrlMode.Absolute)</div>

You should see the URL created with the expected URL mode.

Copilot AI review requested due to automatic review settings September 20, 2025 11:23
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, allowing developers to specify how URLs should be rendered (relative, absolute, etc.) when parsing local links. The change is being ported to version 16.

Key changes:

  • Added new overload to EnsureInternalLinks method accepting UrlMode parameter
  • Updated internal URL generation to respect the specified UrlMode
  • Marked the preview-based overload as obsolete

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/Umbraco.Core/Templates/HtmlLocalLinkParser.cs Added new EnsureInternalLinks overload with UrlMode parameter and updated URL generation logic
src/Umbraco.Core/PropertyEditors/TextStringValueConverter.cs Removed preview parameter from EnsureInternalLinks call
src/Umbraco.Infrastructure/PropertyEditors/ValueConverters/MarkdownEditorValueConverter.cs Removed preview parameter from EnsureInternalLinks call
src/Umbraco.Infrastructure/PropertyEditors/ValueConverters/RteBlockRenderingValueConverter.cs Removed preview parameter from EnsureInternalLinks call
tests/Umbraco.Tests.UnitTests/Umbraco.Core/Templates/HtmlLocalLinkParserTests.cs Added comprehensive unit tests for the new UrlMode functionality

Copy link
Contributor

@kjac kjac left a comment

Choose a reason for hiding this comment

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

Great work, @AndyButland 💪

@kjac kjac enabled auto-merge (squash) September 22, 2025 09:13
@kjac kjac merged commit 8ff11e7 into main Sep 22, 2025
24 of 25 checks passed
@kjac kjac deleted the v16/improvement/html-local-link-parser-url-mode branch September 22, 2025 09:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants