Skip to content

Commit 424730a

Browse files
committed
fix(svelte): restore githubUrl initialization in JsonView template
Reinitialize `githubUrl` inside conditional block to prevent undefined errors when `obj` is not set.
1 parent 97d00f1 commit 424730a

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

src/JsonView.svelte

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@ function toggle() {
2323
metrics.count("ui.json_view.open", 1, { type: obj.type, id: obj.id });
2424
}
2525
}
26-
27-
const githubUrl = `${GAME_REPO_URL}/blob/${buildNumber ?? "upload"}/${obj.__filename}`;
2826
</script>
2927

3028
<section class="json-view">
@@ -35,7 +33,8 @@ const githubUrl = `${GAME_REPO_URL}/blob/${buildNumber ?? "upload"}/${obj.__file
3533
</button>
3634

3735
<div class="actions">
38-
{#if obj.__filename}
36+
{#if obj?.__filename}
37+
{@const githubUrl = `${GAME_REPO_URL}/blob/${buildNumber}/${obj.__filename}`}
3938
<a href={githubUrl} target="_blank" class="github-link"
4039
>{t("GitHub", { _context })}</a>
4140
{/if}

0 commit comments

Comments
 (0)