}, function (err, config) {
        var rawUri, parseOpts, lineIndex = 0, parsedUri, branch, editor, selection
            , projectName, subdir, gitLink, scUrls, workspaceConfiguration;

        workspaceConfiguration = VsCode.workspace.getConfiguration("openInGitHub");
        scUrls = {
            github: 'https://' + workspaceConfiguration.gitHubDomain,
            bitbucket: 'https://bitbucket.org',
            visualstudiocom: /^https:\/\/[\w\d-]*\.visualstudio.com\//
        }

        rawUri = config['remote \"origin\"'].url;
        parseOpts = {
            extraBaseUrls: [
                'bitbucket.org',
                workspaceConfiguration.gitHubDomain
            ]
        }

        rawUri = rawUri.replace('bitbucket.org:', 'bitbucket.org/')

        parsedUri = parse(rawUri, parseOpts);
        if (!parsedUri) {
            parsedUri = rawUri;
        }

        gitRev.branch( cwd, function (branchErr, branch) {
            if (branchErr || !branch)
                branch = 'master';
            editor = Window.activeTextEditor;
            if (editor) {
                selection = editor.selection;

                lineIndex = selection.active.line + 1;
                projectName = parsedUri.substring(parsedUri.lastIndexOf("/") + 1, parsedUri.length);

                subdir = editor.document.uri.fsPath.substring(workspace.rootPath.length).replace(/\"/g, "");

                if (parsedUri.startsWith(scUrls.github)) {
                    gitLink = parsedUri + "/blob/" + branch + subdir + "#L" + lineIndex;
                } else if (parsedUri.startsWith(scUrls.bitbucket)) {
                    gitLink = parsedUri + "/src/" + branch + subdir + "#cl-" + lineIndex;
                } else if (scUrls.visualstudiocom.test(parsedUri)) {
                    gitLink = parsedUri + "#path=" + subdir + "&version=GB" + branch;
                } else {
                    Window.showWarningMessage('Unknown Git provider.');
                }
            } else {
                gitLink = gitLink = parsedUri + "/tree/" + branch;
            }

        if (gitLink)
            cb(gitLink);
        });
    });
    }, function (err, config) {
        var rawUri, parseOpts, parsedUri, branch, projectName,
            subdir, gitLink, scUrls, workspaceConfiguration;

        workspaceConfiguration = VsCode.workspace.getConfiguration("openInGitHub");
        scUrls = {
            github: 'https://' + workspaceConfiguration.gitHubDomain,
            bitbucket: 'https://bitbucket.org',
            visualstudiocom: /^https:\/\/[\w\d-]*\.visualstudio.com\//
        }

        rawUri = config['remote \"origin\"'].url;
        parseOpts = {
            extraBaseUrls: [
                'bitbucket.org',
                workspaceConfiguration.gitHubDomain
            ]
        }

        rawUri = rawUri.replace('bitbucket.org:', 'bitbucket.org/')

        parsedUri = parse(rawUri, parseOpts);
        if (!parsedUri) {
            parsedUri = rawUri;
        }

        gitRev.branch( cwd, function (branchErr, branch) {
            if (branchErr || !branch)
                branch = 'master';

            projectName = parsedUri.substring(parsedUri.lastIndexOf("/") + 1, parsedUri.length);

            subdir = fileFsPath ? fileFsPath.substring(workspace.rootPath.length).replace(/\"/g, "") : undefined;

            if (parsedUri.startsWith(scUrls.github)) {
                gitLink = formGitHubLink(parsedUri, branch, subdir, line);
            } else if (parsedUri.startsWith(scUrls.bitbucket)) {
                gitLink = formBitBucketLink(parsedUri, branch, subdir, line);
            } else if (scUrls.visualstudiocom.test(parsedUri)) {
                gitLink = formVisualStudioLink(parsedUri, subdir, branch, line);
            } else {
                Window.showWarningMessage('Unknown Git provider.');
            }

            if (gitLink)
                cb(gitLink);
        });
    });