Skip to content

Commit 6250c19

Browse files
chore(details): code cleanup
1 parent f98c79e commit 6250c19

File tree

3 files changed

+5
-8
lines changed

3 files changed

+5
-8
lines changed

src/params/number.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
export function match(value: string) {
1+
export function match(value) {
22
return /^\d+$/.test(value);
33
}

src/params/pid.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
export function match(param: string) {
1+
export function match(param) {
22
return param === "pull" || param === "issues" || param === "discussions";
33
}

src/routes/[pid=pid]/[org]/[repo]/[id=number]/+page.server.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,8 @@ import type { BranchCommit } from "$lib/types";
66

77
type Type = "pull" | "issue" | "discussion";
88

9-
export async function load({ params, fetch }) {
10-
const { pid: type, org, repo, id } = params;
11-
const numId = +id; // id is already validated by the route matcher
12-
13-
const item = await githubCache.getItemDetails(org, repo, numId);
9+
export async function load({ params: { pid: type, org, repo, id }, fetch }) {
10+
const item = await githubCache.getItemDetails(org, repo, +id);
1411
if (!item) {
1512
error(404, `${type} #${id} doesn't exist in repo ${org}/${repo}`);
1613
}
@@ -26,7 +23,7 @@ export async function load({ params, fetch }) {
2623
itemMetadata: {
2724
org,
2825
repo,
29-
id: numId,
26+
id: +id,
3027
type: type === "issues" ? "issue" : type === "discussions" ? "discussion" : type
3128
} satisfies {
3229
type: Type;

0 commit comments

Comments
 (0)