diff --git a/cypress/integration/Directory.feature b/cypress/integration/Directory.feature index 29d7bb0..9f0c804 100644 --- a/cypress/integration/Directory.feature +++ b/cypress/integration/Directory.feature @@ -24,3 +24,8 @@ Feature: Directory | chasidic man | haiku/chasidic-man | smells like soup | | in my parents house | haiku/in-my-parents-house | time feels old | | Parent Directory | | Arturo | + + Scenario: I visit a directory with a trailing slash + When I visit "haiku/" + And I click the link "dream haiku" + Then I see "exploding drum" diff --git a/src/components/Directory.svelte b/src/components/Directory.svelte index 6eaab11..22d0da0 100644 --- a/src/components/Directory.svelte +++ b/src/components/Directory.svelte @@ -69,6 +69,13 @@ ? (Math.abs(num) / 1000).toFixed(1) + "k" : `${Math.abs(num)}`; } + + function entryHref(entrySlug: string) { + if (isRoot) { + return `/${entrySlug}` + } + return `/${directory.slug}/${entrySlug}` + } </script> <style> @@ -124,7 +131,7 @@ <td> <a sveltekit:prefetch - href="{directory.slug}/{entry.slug}">{entry.title}</a> + href="{entryHref(entry.slug)}">{entry.title}</a> </td> <td align="right">{entry.date}</td> <td align="right">{format(entry.size)}</td> diff --git a/src/routes/__error.svelte b/src/routes/__error.svelte index fad54ae..82ff05e 100644 --- a/src/routes/__error.svelte +++ b/src/routes/__error.svelte @@ -1,3 +1,11 @@ +<script context="module"> + export function load({ error, status }) { + return { + props: { error, status } + }; + } +</script> + <script lang="ts"> export let status: number; export let error: Error;