Skip to content

Normalize configured app URL#938

Open
leno23 wants to merge 1 commit into
tinyauthapp:mainfrom
leno23:fix/normalize-app-url-937
Open

Normalize configured app URL#938
leno23 wants to merge 1 commit into
tinyauthapp:mainfrom
leno23:fix/normalize-app-url-937

Conversation

@leno23

@leno23 leno23 commented Jun 15, 2026

Copy link
Copy Markdown

Closes #937.

Summary

  • Route configured app URL normalization through a dedicated helper before it is used to build login and OAuth redirect URLs.
  • Add regression coverage for trailing-slash, path, and explicit-port app URLs so login redirects do not gain a double slash.

Verification

  • gofmt -w internal/bootstrap/app_bootstrap.go internal/bootstrap/app_bootstrap_test.go
  • git diff --check
  • GOTOOLCHAIN=local go test ./internal/bootstrap fails before running tests because the local Go toolchain is 1.26.2 while go.mod requires Go 1.26.4.
  • go test ./internal/bootstrap started downloading Go 1.26.4 but did not complete in several minutes, so it was terminated to avoid blocking.

Summary by CodeRabbit

  • Bug Fixes

    • Improved application URL normalization to consistently handle various URL formats, including trailing slashes and explicit ports.
  • Tests

    • Added comprehensive unit tests for URL handling validation.

@dosubot dosubot Bot added the size:XS This PR changes 0-9 lines, ignoring generated files. label Jun 15, 2026
@coderabbitai

coderabbitai Bot commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 660d7224-bd90-400e-b4d0-656f636103c4

📥 Commits

Reviewing files that changed from the base of the PR and between a0e74cd and aeda758.

📒 Files selected for processing (2)
  • internal/bootstrap/app_bootstrap.go
  • internal/bootstrap/app_bootstrap_test.go

📝 Walkthrough

Walkthrough

A new unexported normalizeAppURL(*url.URL) string helper is added to app_bootstrap.go, returning only scheme://host. Setup() is updated to use this helper when assigning app.runtime.AppURL. A new test file adds table-driven cases covering trailing-slash removal, path-segment stripping, and port preservation.

Changes

normalizeAppURL helper and tests

Layer / File(s) Summary
normalizeAppURL helper and Setup() wiring
internal/bootstrap/app_bootstrap.go
Adds normalizeAppURL(appUrl *url.URL) string returning scheme://host, and updates the Setup() call site to use it instead of inline string composition.
Table-driven tests
internal/bootstrap/app_bootstrap_test.go
Adds TestNormalizeAppURL with three cases: trailing-slash trimming, configured-path ignoring, and explicit-port preservation.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Poem

🐇 A slash at the end caused a login to break,
So I nibbled the path for the URL's sake.
scheme://host is all that you need,
No trailing confusion, no double-slash greed.
With tests to confirm every trim and each port,
This rabbit's done fixing that URL contort! 🥕

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Normalize configured app URL' clearly and concisely describes the main change: a new helper function that normalizes the app URL configuration.
Linked Issues check ✅ Passed The PR successfully addresses issue #937 by implementing URL normalization that trims trailing slashes and handles paths correctly, with comprehensive test coverage for multiple URL formats.
Out of Scope Changes check ✅ Passed All changes directly support the URL normalization objective: the new normalizeAppURL helper and its comprehensive unit tests are fully aligned with the requirements from issue #937.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

size:XS This PR changes 0-9 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Trailing slash in docker-compose.yml will break login direct

1 participant