Skip to content

Commit d831a72

Browse files
authored
Change regex test against url in goto to include about:* (#2376)
1 parent 6179d46 commit d831a72

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

lib/taiko.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -733,7 +733,7 @@ module.exports.goto = async (
733733
options = { navigationTimeout: defaultConfig.navigationTimeout },
734734
) => {
735735
validate();
736-
if (!/:\/\//i.test(url)) {
736+
if (!/^about:|:\/\//i.test(url)) {
737737
url = 'http://' + url;
738738
}
739739
if (options.headers) {

test/unit-tests/goto.test.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,20 @@ describe(test_name, () => {
8383
expect(actualUrl).to.equal(expectedUrl);
8484
});
8585

86+
it('should not add protocol http:// if url is "about:*"', async () => {
87+
let aboutBlank = 'about:randomString';
88+
let expectedUrl = aboutBlank;
89+
await taiko.goto(aboutBlank);
90+
expect(actualUrl).to.equal(expectedUrl);
91+
});
92+
93+
it('should add protocol http:// for url with port specified', async () => {
94+
let urlWithPort = 'localhost:8080';
95+
let expectedUrl = 'http://' + urlWithPort;
96+
await taiko.goto(urlWithPort);
97+
expect(actualUrl).to.equal(expectedUrl);
98+
});
99+
86100
it('should configure provided headers for the domain', async () => {
87101
let options = {
88102
headers: { Authorization: 'Basic cG9zdG1hbjpwYXNzd29y2A==' },

0 commit comments

Comments
 (0)