Skip to content

fix(routing): preserve query string on redirect and fix root sub-route crash#308

Merged
usernane merged 1 commit intomainfrom
dev
Apr 29, 2026
Merged

fix(routing): preserve query string on redirect and fix root sub-route crash#308
usernane merged 1 commit intomainfrom
dev

Conversation

@usernane
Copy link
Copy Markdown
Member

Summary

Two routing bug fixes: preserve query string parameters during redirects, and prevent crash when grouping sub-routes under root path "/".

Motivation

Changes

  • In Router::redirect() closure, read query string from the requested URI via Router::getRouteUri()->getRequestedUri() and append it to the redirect target
  • In fixUriPath(), added strlen($path) > 0 guard to the while loop condition

How to Test / Verify

Breaking Changes and Migration Steps

None

Checklist

  • I reviewed my own diff before requesting review
  • My commits follow Conventional Commits
  • The title of the pull request follows Conventional Commits
  • I added/updated tests (or explained why not)
  • I updated docs (if needed)
  • I ran lint/cs-fixer (if applicable)
  • I considered backward compatibility
  • I considered security

Related issues

Closes #302
Closes #303

…root sub-routes

- Router::redirect() now forwards query string parameters from the
  original request to the redirect target. Fixes #303.

- fixUriPath() now checks strlen before accessing $path[0] in the
  while loop, preventing 'Uninitialized string offset 0' when
  grouping sub-routes under root path '/'. Fixes #302.
@usernane usernane merged commit 3250d15 into main Apr 29, 2026
8 of 9 checks passed
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 29, 2026

Codecov Report

❌ Patch coverage is 75.00000% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 74.89%. Comparing base (9c5c3b6) to head (007c799).
⚠️ Report is 10 commits behind head on main.

Files with missing lines Patch % Lines
WebFiori/Framework/Router/Router.php 75.00% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main     #308      +/-   ##
============================================
- Coverage     74.89%   74.89%   -0.01%     
- Complexity     2973     2976       +3     
============================================
  Files            97       97              
  Lines          9508     9511       +3     
============================================
+ Hits           7121     7123       +2     
- Misses         2387     2388       +1     
Flag Coverage Δ
php-8.1 76.21% <75.00%> (-0.01%) ⬇️
php-8.2 76.16% <75.00%> (-0.01%) ⬇️
php-8.3 74.96% <75.00%> (-0.01%) ⬇️
php-8.4 74.96% <75.00%> (-0.01%) ⬇️
php-8.5 74.86% <75.00%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@sonarqubecloud
Copy link
Copy Markdown

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.

bug(routing): Router::redirect() drops query string parameters bug(routing): Uninitialized string offset when grouping sub-routes under root path '/'

1 participant