Skip to content

Commit

Permalink
refactor: replace duplicate Regex
Browse files Browse the repository at this point in the history
  • Loading branch information
olivierdagenais committed Sep 6, 2024
1 parent 4c71d4f commit ded290d
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions src/parsers/Bitbucket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ const commitListUrlRegex = /commits\?until=(?<ref>[^&]+)(&.+)?/;
const deepCommitUrlRegex =
/commits\/(?<ref>[^#]+)(#(?<path>[^?]+)(\?[ft]=(?<lineNumber>\d+))?)?/;
const prUrlRegex = /pull-requests\/(?<prId>\d+)(\/(?<extra>.*))?/;
const prExtraRegex =
/commits\/(?<ref>[^#]+)(#(?<path>[^?]+)(\?[ft]=(?<lineNumber>\d+))?)?/;

export class Bitbucket extends AbstractParser {
parseLink(doc: Document, url: string): Link | null {
Expand Down Expand Up @@ -201,7 +199,7 @@ export class Bitbucket extends AbstractParser {
const summary = h2Element.textContent;
var prefix = "";
if (extra) {
const prExtraMatch = extra.match(prExtraRegex);
const prExtraMatch = extra.match(deepCommitUrlRegex);
if (prExtraMatch && prExtraMatch.groups) {
const prExtraGroups = prExtraMatch.groups;
prefix = this.prefixForLinePathCommit(prExtraGroups);
Expand Down

0 comments on commit ded290d

Please sign in to comment.