Skip to content

Commit

Permalink
Merge pull request #215 from getgauge/175_close_tab
Browse files Browse the repository at this point in the history
  • Loading branch information
NivedhaSenthil committed Oct 11, 2018
2 parents b664dd3 + 0279bb7 commit 551c6e9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
2 changes: 1 addition & 1 deletion lib/api.json

Large diffs are not rendered by default.

12 changes: 4 additions & 8 deletions lib/targetHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,11 @@ const getCriTarget = async (targetURL) => {

const getTargetToConnect = async (targetUrl) => {
const targets = (await criTarget.getTargets()).targetInfos;
let targetToConnect;
targetUrl = handleUrlRedirection(targetUrl);
for (const target of targets) {
target.url = handleUrlRedirection(target.url);
if (target.type === 'page' && (target.url.split('://')[1] !== (targetUrl.split('://')[1] || targetUrl)) && (target.url !== targetUrl)) {
targetToConnect = target;
}
}
return targetToConnect;
return targets.find( ( target ) => {
let _targetUrl = handleUrlRedirection(target.url);
return target.type === 'page' && (_targetUrl.split('://')[1] !== (targetUrl.split('://')[1] || targetUrl)) && (_targetUrl !== targetUrl);
});
};

const handleUrlRedirection = (url) => {
Expand Down

0 comments on commit 551c6e9

Please sign in to comment.