Skip to content

Commit 96d86e0

Browse files
committed
Cleanup releases.ts
1 parent ef78963 commit 96d86e0

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

src/utils/releases.ts

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -51,14 +51,8 @@ export async function fetchRelease(repo: string): Promise<Release[]> {
5151
// Post-processing
5252
.map((obj) => {
5353
handleRegex(obj, /\@(\w|\d|\-)+/g, (match) => `[${match}](https://github.com/${match.substring(1)})`);
54-
handleRegex(obj, /https\:\/\/github\.com\/\w+\/\w+\/pull\/\d+/g, (match) => {
55-
const split: string[] = match.split("/");
56-
return `[#${split[split.length - 1]}](${match})`;
57-
});
58-
handleRegex(obj, /https\:\/\/github\.com\/\w+\/\w+\/compare\/[v\.\d]+/g, (match) => {
59-
const split: string[] = match.split("/");
60-
return `[${split[split.length - 1]}](${match})`;
61-
});
54+
handleRegex(obj, /https\:\/\/github\.com\/\w+\/\w+\/pull\/\d+/g, shortCut);
55+
handleRegex(obj, /https\:\/\/github\.com\/\w+\/\w+\/compare\/[v\.\d]+/g, shortCut);
6256
return obj;
6357
})
6458
.map((obj) => {
@@ -104,3 +98,8 @@ function handleRegex(obj: Release, regex: RegExp, onMatch: (match: string) => st
10498
alreadyMatched.push(match);
10599
});
106100
}
101+
102+
function shortCut(match: string): string {
103+
const split: string[] = match.split("/");
104+
return `[${split[split.length - 1]}](${match})`;
105+
}

0 commit comments

Comments
 (0)