Sidebar custom link strips internal hostname from query parameters of external URLs

When saving a sidebar custom link with an external URL that contains the site’s own hostname inside a query parameter, the hostname is incorrectly stripped
from the query parameter, breaking the URL.

Steps to reproduce

  1. Go to sidebar settings and add/edit a custom link
  2. Set the URL to an external URL that includes your site’s hostname in a query parameter, for example a YouTube redirect URL pointing back to your own site
  3. Save

Expected behavior

The full URL is preserved as entered, including the hostname in the query parameter.

Actual behavior

The site’s hostname is stripped from the query parameter. For example, the query parameter portion changes from ?q=https://mysite.com/some-path/ to
?q=/some-path/, producing a broken redirect URL.

Use case

Our forum (teskas.net, a Tesla owners community) has a sidebar link that uses a YouTube redirect endpoint to trigger fullscreen mode on Tesla in-car
browser. The query parameter must contain our full site URL including hostname for the redirect to work.

Workaround

URL-encode the hostname portion in the query parameter and write directly to the database, bypassing the form normalization.

Environment

  • Self-hosted, Discourse v2026.3.0-latest
1 like