Skip to content

Commit b898148

Browse files
committed
Use switch-based recursion property mapping
Switch getRecursiveTargetId() to an explicit switch statement for recurseProperty handling. This keeps the mapping table-style and easier to extend as additional recurse properties are introduced. #608 (comment)
1 parent f00210c commit b898148

1 file changed

Lines changed: 13 additions & 13 deletions

File tree

packages/cli/src/lookup.ts

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -545,20 +545,20 @@ export function getRecursiveTargetId(
545545
object: APObject,
546546
recurseProperty: RecurseProperty,
547547
): URL | null {
548-
if (
549-
recurseProperty === "replyTarget" || recurseProperty === IN_REPLY_TO_IRI
550-
) {
551-
return object.replyTargetId;
552-
}
553-
if (
554-
recurseProperty === "quoteUrl" || recurseProperty === QUOTE_URL_IRI ||
555-
recurseProperty === MISSKEY_QUOTE_IRI ||
556-
recurseProperty === FEDIBIRD_QUOTE_IRI
557-
) {
558-
const quoteUrl = (object as { quoteUrl?: unknown }).quoteUrl;
559-
return quoteUrl instanceof URL ? quoteUrl : null;
548+
switch (recurseProperty) {
549+
case "replyTarget":
550+
case IN_REPLY_TO_IRI:
551+
return object.replyTargetId;
552+
case "quoteUrl":
553+
case QUOTE_URL_IRI:
554+
case MISSKEY_QUOTE_IRI:
555+
case FEDIBIRD_QUOTE_IRI: {
556+
const quoteUrl = (object as { quoteUrl?: unknown }).quoteUrl;
557+
return quoteUrl instanceof URL ? quoteUrl : null;
558+
}
559+
default:
560+
return null;
560561
}
561-
return null;
562562
}
563563

564564
/**

0 commit comments

Comments
 (0)