Skip to content

Commit

Permalink
fix: correct PR URL matching
Browse files Browse the repository at this point in the history
  • Loading branch information
z0al committed Dec 12, 2020
1 parent 483aa39 commit fa75802
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 7 deletions.
4 changes: 2 additions & 2 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions src/__tests__/helpers.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ test('DependencyExtractor', () => {
- Full issue URL:
- Depends on https://github.com/another/repo/issues/141
- Depends on http://github.com/another/repo/issues/404
- Depends on https://github.com/another/repo/pulls/142
- Depends on https://github.com/another/repo/pull/142
- Crazy formatting:
- Depends on ano-ther.999/re_po#123
- In brackets:
Expand All @@ -49,6 +49,7 @@ test('DependencyExtractor', () => {
- Depends on user_repo#123
- Depends on this/is/not/repo#123
- Depends on #123hashtag
- Depends on https://github.com/another/repo/pulls/142
`;

const issue = { body } as Issue;
Expand Down Expand Up @@ -82,7 +83,7 @@ test('DependencyExtractor', () => {
repo: 'repo',
number: 404,
},
// Depends on https://github.com/another/repo/pulls/142
// Depends on https://github.com/another/repo/pull/142
{
owner: 'another',
repo: 'repo',
Expand Down
4 changes: 2 additions & 2 deletions src/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export function formatDependency(dep: Dependency, repo?: Repository) {
export class DependencyExtractor {
private regex: RegExp;
private issueRegex = IssueRegex();
private urlRegex = /https?:\/\/github\.com\/(?:\w[\w-.]+\/\w[\w-.]+|\B)\/(?:issues|pulls)\/[1-9]\d*\b/;
private urlRegex = /https?:\/\/github\.com\/(?:\w[\w-.]+\/\w[\w-.]+|\B)\/(?:issues|pull)\/[1-9]\d*\b/;
private keywordRegex: RegExp;

constructor(private repo: Repository, keywords: string[]) {
Expand Down Expand Up @@ -62,7 +62,7 @@ export class DependencyExtractor {
// 'owner/repo#number' format
return ref
.replace(/https?:\/\/github\.com\//i, '')
.replace(/\/(issues|pulls)\//i, '#');
.replace(/\/(issues|pull)\//i, '#');
});
}

Expand Down

0 comments on commit fa75802

Please sign in to comment.