Skip to content

Commit 5fa9f66

Browse files
Bayheckadil.rakhaliyev
andauthored
Fix: TypeError Invalid URL error in prepareBaseUrl (#8470)
<!-- 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 <[email protected]>
1 parent 8793e89 commit 5fa9f66

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/api/test-page-url.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import OS from 'os-family';
33
import { APIError } from '../errors/runtime';
44
import { RUNTIME_ERRORS } from '../errors/types';
55
import { SPECIAL_BLANK_PAGE } from 'testcafe-hammerhead';
6-
import { join } from 'path';
76

87
const PROTOCOL_RE = /^([\w-]+?)(?=:\/\/)/;
98
const SUPPORTED_PROTOCOL_RE = /^(https?|file):/;
@@ -51,7 +50,9 @@ export function getUrl (url: string, base?: URL): string {
5150
}
5251

5352
export function prepareBaseUrl (url: string): URL {
54-
url = join(url, '/');
53+
if (!url.endsWith('/'))
54+
url += '/';
55+
5556
return isAbsolute(url) ? pathToFileURL(url) : new URL(url);
5657
}
5758

0 commit comments

Comments
 (0)