Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
UPDATE "Project"
SET "prDescriptionFetchedAt" = NULL,
"prShortDescription" = NULL
WHERE "prDescriptionFetchedAt" IS NOT NULL
AND "prShortDescription" IS NULL
AND "prUrl" ~ '^https?://(www\.)?github\.com/[^/]+/[^/]+/pull/[0-9]+/[^/?#]';
15 changes: 15 additions & 0 deletions src/github/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,26 @@ function assertEqual<T>(actual: T, expected: T, message: string): void {
{ owner: 'codeday', repo: 'labs-gql', number: 42 },
'parses owner/repo/number from a pull request URL',
);
assertEqual(
parseGithubPullRequestUrl('https://github.com/codeday/labs-gql/pull/42/files'),
{ owner: 'codeday', repo: 'labs-gql', number: 42 },
'parses a PR URL with a trailing tab segment (e.g. /files)',
);
assertEqual(
parseGithubPullRequestUrl('https://github.com/codeday/labs-gql/pull/42/files/diff/abc123'),
{ owner: 'codeday', repo: 'labs-gql', number: 42 },
'parses a PR URL with multiple trailing path segments (deep link)',
);
assertEqual(
parseGithubPullRequestUrl('https://github.com/codeday/labs-gql/issues/42'),
null,
'rejects an issue URL',
);
assertEqual(
parseGithubPullRequestUrl('https://github.com/codeday/labs-gql/issues/42/files'),
null,
'rejects an issue URL with a trailing segment',
);
assertEqual(
parseGithubPullRequestUrl('https://github.com/codeday/labs-gql'),
null,
Expand Down
2 changes: 1 addition & 1 deletion src/github/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import fetch from 'node-fetch';
import config from '../config';

const GITHUB_URL_RE = /^https?:\/\/(?:www\.)?github\.com\/([^/\s]+)\/([^/\s#?]+?)(?:\.git)?(?:\/(issues|pull)\/(\d+))?\/?(?:[?#].*)?$/i;
const GITHUB_URL_RE = /^https?:\/\/(?:www\.)?github\.com\/([^/\s]+)\/([^/\s#?]+?)(?:\.git)?(?:\/(issues|pull)\/(\d+)(?:\/[^/?#]+)*?)?\/?(?:[?#].*)?$/i;

export interface GithubRepoRef {
owner: string;
Expand Down
Loading