Skip to content

fix(feature): build url shortener feature url with trailing slash#32

Merged
konradmichalik merged 1 commit into
mainfrom
fix/url-shortener-trailing-slash
Jun 22, 2026
Merged

fix(feature): build url shortener feature url with trailing slash#32
konradmichalik merged 1 commit into
mainfrom
fix/url-shortener-trailing-slash

Conversation

@konradmichalik

@konradmichalik konradmichalik commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Fix initUrlShortener() so the generated feature URL is built slash-robust and always ends with /, independent of whether public_urls is configured with or without a trailing slash
  • Previously the branch was appended directly ("https://host/" . "BRANCH"https://host/BRANCH, no trailing slash), corrupting DEPLOYER_CONFIG_FEATURE_URL (TYPO3_BASEURL) in consumer projects
  • That broke the TYPO3 site base and all values derived from it via string concatenation (e.g. %env(TYPO3_BASEURL)%sitemap.xml, errorContentSource) → broken absolute URLs, breadcrumbs, and 504 hangs on error

Changes

  • deployer/feature/task/url_shortener.phpinitUrlShortener() now builds the URL as rtrim($publicUrl, '/') . '/' . $feature . '/'

Verification

For branch FOO-123, DEPLOYER_CONFIG_FEATURE_URL resolves to exactly https://stage.example.de/FOO-123/ for both input variants:

public_urls input Result
https://stage.example.de/ https://stage.example.de/FOO-123/
https://stage.example.de (no trailing slash) https://stage.example.de/FOO-123/

Other concatenation sites in the package (deploy_path, dev/config/set.php, feature_scheduler.php) join with feature_url_shortener_path, which ends in / by default — no double slashes introduced. No automated test framework exists in this Deployer recipe package, so verification was done manually.

⚠️ Re-init required

Feature config files are generated only once (once-generated feature_templates). Existing feature instances must re-init (re-run feature:setup / regenerate their generated config) for the corrected URL to take effect.

Summary by CodeRabbit

  • Bug Fixes

    • Improved URL shortening to handle trailing slashes more consistently across shortened URLs.
  • Refactor

    • Optimized internal control flow structure for deployment task gating logic.

initUrlShortener() appended the branch directly to public_urls without a
trailing slash, so DEPLOYER_CONFIG_FEATURE_URL (TYPO3_BASEURL) became
"https://host/BRANCH". Consumer projects derive the site base and string-
concatenated values (e.g. %env(TYPO3_BASEURL)%sitemap.xml) from it, which
broke absolute URLs/breadcrumbs and caused 504 hangs.

Build the URL slash-robust so it always ends with "/" regardless of whether
public_urls is configured with or without a trailing slash:
rtrim($publicUrl, '/') . '/' . $feature . '/'.

NOTE: feature .env files are generated only once ("once generated"
feature_templates). Existing feature instances must re-init (re-run
feature:setup / re-generate .env) for the corrected URL to take effect.
@konradmichalik konradmichalik merged commit 4e60b76 into main Jun 22, 2026
1 check passed
@coderabbitai

coderabbitai Bot commented Jun 22, 2026

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 56daa5a9-0fd3-4248-af26-50d5c3402dca

📥 Commits

Reviewing files that changed from the base of the PR and between 86b89d4 and 7c12ffe.

📒 Files selected for processing (1)
  • deployer/feature/task/url_shortener.php

📝 Walkthrough

Walkthrough

In deployer/feature/task/url_shortener.php, early-return guard conditions are converted from single-line to braced-block form. The initUrlShortener() function's URL construction is changed to trim trailing slashes from each base URL and rebuild paths with explicit / separators and a trailing /.

Changes

URL Shortener Task Fixes

Layer / File(s) Summary
Guard refactor and URL path construction fix
deployer/feature/task/url_shortener.php
Guard conditions converted to braced early-return blocks; public_urls construction replaced from publicUrl . $feature to rtrim($publicUrl, '/') . '/' . $feature . '/' ensuring consistent slash handling.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~5 minutes

Poem

A rabbit hops down the path with glee,
Trimming the slashes so URLs are free!
No more stray / at the end of the base,
Each shortened link now lands in the right place.
🐇✂️ Tidy paths for all to see!

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/url-shortener-trailing-slash

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 PHPStan (2.2.2)

PHPStan was skipped because the config uses disallowed bootstrapFiles, bootstrapFile, or includes directives.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

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.

1 participant