diff --git a/src/parsers/Bitbucket.ts b/src/parsers/Bitbucket.ts index 7b50a40..9701640 100644 --- a/src/parsers/Bitbucket.ts +++ b/src/parsers/Bitbucket.ts @@ -155,24 +155,29 @@ export class Bitbucket extends AbstractParser { repo: string, deepCommitUrlGroups: { [key: string]: string } ) { + const prefix = this.prefixForLinePathCommit(deepCommitUrlGroups); + const linkText = `${prefix}${project}/${repo}`; + const result: Link = { + text: linkText, + destination: url, + }; + return result; + } + + private prefixForLinePathCommit(groups: { [key: string]: string }): string { var prefix = ""; - const path = deepCommitUrlGroups.path; + const path = groups.path; if (path) { - const lineNumber = deepCommitUrlGroups.lineNumber; + const lineNumber = groups.lineNumber; if (lineNumber) { prefix += `line ${lineNumber} of `; } const decodedPath = decodeURIComponent(path); prefix += `${decodedPath} at `; } - const ref = this.getPrettyRef(deepCommitUrlGroups); + const ref = this.getPrettyRef(groups); prefix += `commit ${ref} in `; - const linkText = `${prefix}${project}/${repo}`; - const result: Link = { - text: linkText, - destination: url, - }; - return result; + return prefix; } private parsePullRequest( @@ -199,17 +204,7 @@ export class Bitbucket extends AbstractParser { const prExtraMatch = extra.match(prExtraRegex); if (prExtraMatch && prExtraMatch.groups) { const prExtraGroups = prExtraMatch.groups; - const path = prExtraGroups.path; - if (path) { - const lineNumber = prExtraGroups.lineNumber; - if (lineNumber) { - prefix += `line ${lineNumber} of `; - } - const decodedPath = decodeURIComponent(path); - prefix += `${decodedPath} at `; - } - const ref = this.getPrettyRef(prExtraGroups); - prefix += `commit ${ref} in `; + prefix = this.prefixForLinePathCommit(prExtraGroups); } }