Skip to content

Commit

Permalink
fix: avoid trailing slashes on downloads
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanprobst committed Jun 12, 2024
1 parent 0de1baf commit 29695dd
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
4 changes: 1 addition & 3 deletions src/components/content/download.astro
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,4 @@ interface Props {
const { href } = Astro.props;
---

<a download href={href}>
<slot />
</a>
<a download="" href={href}><slot /></a>
4 changes: 1 addition & 3 deletions src/components/navigation/nav-link.astro
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,4 @@ const pathname = href != null ? (typeof href === "string" ? href : href.pathname
const isCurrent = pathname === Astro.url.pathname;
---

<a {...rest} aria-current={isCurrent ? "page" : undefined} href={href}>
<slot />
</a>
<a {...rest} aria-current={isCurrent ? "page" : undefined} href={href}><slot /></a>
4 changes: 4 additions & 0 deletions src/lib/ensure-trailing-slash.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
const hasFileExtension = /\.\w+?$/;

export function ensureTrailingSlash(path: string): string {
if (hasFileExtension.test(path)) return path;

return path.endsWith("/") ? path : path + "/";
}

0 comments on commit 29695dd

Please sign in to comment.