Skip to content

Commit

Permalink
Change regex test against url in goto to include about:* (#2376)
Browse files Browse the repository at this point in the history
  • Loading branch information
radhey-sahaj authored Apr 4, 2023
1 parent 6179d46 commit d831a72
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/taiko.js
Original file line number Diff line number Diff line change
Expand Up @@ -733,7 +733,7 @@ module.exports.goto = async (
options = { navigationTimeout: defaultConfig.navigationTimeout },
) => {
validate();
if (!/:\/\//i.test(url)) {
if (!/^about:|:\/\//i.test(url)) {
url = 'http://' + url;
}
if (options.headers) {
Expand Down
14 changes: 14 additions & 0 deletions test/unit-tests/goto.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,20 @@ describe(test_name, () => {
expect(actualUrl).to.equal(expectedUrl);
});

it('should not add protocol http:// if url is "about:*"', async () => {
let aboutBlank = 'about:randomString';
let expectedUrl = aboutBlank;
await taiko.goto(aboutBlank);
expect(actualUrl).to.equal(expectedUrl);
});

it('should add protocol http:// for url with port specified', async () => {
let urlWithPort = 'localhost:8080';
let expectedUrl = 'http://' + urlWithPort;
await taiko.goto(urlWithPort);
expect(actualUrl).to.equal(expectedUrl);
});

it('should configure provided headers for the domain', async () => {
let options = {
headers: { Authorization: 'Basic cG9zdG1hbjpwYXNzd29y2A==' },
Expand Down

0 comments on commit d831a72

Please sign in to comment.