Skip to content

fix: prevent Invalid URL error in prepareBaseUrl for http/https baseUrl - #8434

Closed
yasinkocak wants to merge 4 commits into
DevExpress:masterfrom
yasinkocak:master
Closed

fix: prevent Invalid URL error in prepareBaseUrl for http/https baseUrl#8434
yasinkocak wants to merge 4 commits into
DevExpress:masterfrom
yasinkocak:master

Conversation

@yasinkocak

@yasinkocak yasinkocak commented Aug 19, 2025

Copy link
Copy Markdown

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
@github-actions

Copy link
Copy Markdown

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

Bayheck added a commit that referenced this pull request Dec 29, 2025
<!--
Thank you for your contribution.

Before making a PR, please read our contributing guidelines at

https://github.com/DevExpress/testcafe/blob/master/CONTRIBUTING.md#code-contribution

We recommend creating a *draft* PR, so that you can mark it as 'ready
for review' when you are done.
-->

## Purpose
_Describe the problem you want to address or the feature you want to
implement._

## Approach
_Describe how your changes address the issue or implement the desired
functionality in as much detail as possible._

## References
closes #8434
closes #8364

## Pre-Merge TODO
- [ ] Write tests for your proposed changes
- [ ] Make sure that existing tests do not fail

---------

Co-authored-by: adil.rakhaliyev <adil.rakhaliyev@devexpress.com>
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