Skip to content

fix(app): trim URLs before openUrl http fallback#1954

Merged
senamakel merged 3 commits into
tinyhumansai:mainfrom
MackDing:fix-openurl-trim-http-fallback
May 17, 2026
Merged

fix(app): trim URLs before openUrl http fallback#1954
senamakel merged 3 commits into
tinyhumansai:mainfrom
MackDing:fix-openurl-trim-http-fallback

Conversation

@MackDing
Copy link
Copy Markdown
Contributor

@MackDing MackDing commented May 16, 2026

Summary

  • trim incoming URLs at the start of openUrl() so surrounding whitespace does not change fallback behavior
  • use the normalized URL consistently for tauriOpenUrl, telemetry redaction, HTTP classification, and window.open
  • add a regression test covering a whitespace-padded https://... URL when tauriOpenUrl fails with Cannot read properties of undefined (reading 'postMessage')

Why

isHttpUrl() previously classified the raw input string. If a valid http(s) URL arrived with leading or trailing whitespace, the Tauri fallback path could misclassify it as non-http and rethrow instead of opening it in the browser.

Validation

  • pnpm --filter openhuman-app compile
  • pnpm --filter openhuman-app test -- src/utils/openUrl.test.ts (the repo's Vitest setup fans out broadly, but this change was validated in the local test run and the new regression test is included)

Note

A local git hook attempted to run repository-wide formatting and failed in this environment due a Rust toolchain/rustup conflict unrelated to this JS/TS-only change.

Summary by CodeRabbit

  • Bug Fixes

    • URL opener now trims surrounding whitespace from input URLs before processing, ensuring consistent opening and fallback behavior.
  • Tests

    • Added unit tests to verify URL whitespace trimming and correct fallback handling when primary opening method fails.

Review Change Stack

@MackDing MackDing requested a review from a team May 16, 2026 17:29
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 16, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: de5ec0e7-528b-487a-a10a-fffd6c3cfa2f

📥 Commits

Reviewing files that changed from the base of the PR and between 65754fa and 80f92cd.

📒 Files selected for processing (1)
  • app/src/utils/openUrl.test.ts

📝 Walkthrough

Walkthrough

openUrl and its isHttpUrl helper now trim surrounding whitespace from input URLs. The utility normalizes URLs once and applies the trimmed value throughout Tauri dispatch, telemetry breadcrumb recording, HTTP fallback classification, and browser open calls. A new test verifies the trimming behavior when Tauri IPC fails.

Changes

URL whitespace normalization

Layer / File(s) Summary
URL trimming implementation and test
app/src/utils/openUrl.ts, app/src/utils/openUrl.test.ts
isHttpUrl trims whitespace before regex check. openUrl normalizes the input URL once and applies the trimmed value to Tauri dispatch, telemetry breadcrumb data, the HTTP fallback condition, and the final window.open call. A unit test asserts trimming occurs before Tauri and fallback handling, and verifies the breadcrumb records only the trimmed origin.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 A URL with spaces came hopping by,
I clipped its edges, let its scheme fly.
Tauri tried first, then browser took flight,
Breadcrumbs kept origin, all clean and bright.
Hooray — trimmed links and peaceful night!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically describes the main change: trimming URLs before HTTP fallback handling in the openUrl function.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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

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.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

ESLint skipped: no ESLint configuration detected in root package.json. To enable, add eslint to devDependencies.


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.

coderabbitai[bot]
coderabbitai Bot previously approved these changes May 16, 2026
senamakel
senamakel previously approved these changes May 17, 2026
@senamakel senamakel dismissed stale reviews from coderabbitai[bot] and themself via 80f92cd May 17, 2026 03:44
@senamakel senamakel merged commit e5f5ce0 into tinyhumansai:main May 17, 2026
24 checks passed
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.

2 participants