testcafe
testcafe copied to clipboard
fix: prevent Invalid URL error in prepareBaseUrl for http/https baseUrl
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/")→ throwsTypeError: Invalid URL
This breaks .page(...) and config-based baseUrl when using standard web URLs.
Expected behavior
baseUrlis always treated as a web URL if it starts withhttp://orhttps://.- File system paths should still resolve correctly to
file://.
How does this PR fix the problem?
- Detects and preserves
http://andhttps://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
Thank you for your contribution to TestCafe. When a member of the TestCafe team becomes available, they will review this PR.