Skip to content

Commit

Permalink
Fix openTab navigation to non http url (#2652)
Browse files Browse the repository at this point in the history
Signed-off-by: Arun Kumar <[email protected]>

Signed-off-by: Arun Kumar <[email protected]>
Co-authored-by: Arun Kumar <[email protected]>
  • Loading branch information
arun04arun95 and Arun Kumar authored Oct 26, 2022
1 parent 8021586 commit 4f4087e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
3 changes: 1 addition & 2 deletions lib/taiko.js
Original file line number Diff line number Diff line change
Expand Up @@ -382,8 +382,7 @@ module.exports.openTab = async (targetUrl, options = {}) => {
if (
isString(targetUrl) &&
targetUrl != 'about:blank' &&
!/^https?:\/\//i.test(targetUrl) &&
!/^file/i.test(targetUrl)
!/:\/\//i.test(targetUrl)
) {
targetUrl = 'http://' + targetUrl;
}
Expand Down
4 changes: 4 additions & 0 deletions test/unit-tests/openTab.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ describe('openTab', () => {
expectedUrl = 'file://example.com';
await taiko.openTab(expectedUrl);
expect(actualUrl).to.equal(expectedUrl);

expectedUrl = 'chrome-extension://gjaerjgaerjeoareapoj/internalPage.html';
await taiko.openTab(expectedUrl);
expect(actualUrl).to.equal(expectedUrl);
});

it('should add protocol http:// if not given', async () => {
Expand Down

0 comments on commit 4f4087e

Please sign in to comment.