Skip to content

Conversation

yasinkocak
Copy link

@yasinkocak yasinkocak commented Aug 19, 2025

What does this PR do?

Fixes an Invalid URL error that occurs when using baseUrl with http or https values in TestCafe 3.7.1+ on Node.js 20.18+.

Current behavior

The current implementation of prepareBaseUrl applies path.join to the provided baseUrl.
For web URLs, this produces invalid results:

  • Input: "http://devexpress.github.io"
  • Result after path.join: "http:/devexpress.github.io/"
  • new URL("http:/devexpress.github.io/") → throws TypeError: Invalid URL

This breaks .page(...) and config-based baseUrl when using standard web URLs.

Expected behavior

  • baseUrl is always treated as a web URL if it starts with http:// or https://.
  • File system paths should still resolve correctly to file://.

How does this PR fix the problem?

  • Detects and preserves http:// and https:// URLs (adds trailing slash if missing).
  • Allows explicit file:// URLs.
  • Falls back to converting absolute/relative file system paths via pathToFileURL.

Related issue

Fixes #8364

@testcafe-need-response-bot testcafe-need-response-bot bot added the STATE: Need response An issue that requires a response or attention from the team. label Aug 19, 2025
@Bayheck Bayheck added STATE: PR Review Pending A note that this PR will be reviewed. and removed STATE: Need response An issue that requires a response or attention from the team. labels Aug 21, 2025
Copy link

Thank you for your contribution to TestCafe. When a member of the TestCafe team becomes available, they will review this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

STATE: PR Review Pending A note that this PR will be reviewed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Suddenly TypeError: Invalid URL

2 participants