Skip to content

Commit

Permalink
fix(gatsby): use standard links for file downloads
Browse files Browse the repository at this point in the history
  • Loading branch information
pmelab committed Nov 15, 2023
1 parent cb7b0ed commit ddc8e48
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion packages/npm/@amazeelabs/scalars/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,14 @@ const isRelative = (url?: Url | LocationType) =>
url?.startsWith('?') ||
Boolean(url?.match(/^\/(?!\/)/));

const isDownload = (url?: Url | LocationType) =>
isLocation(url) || Boolean(url?.match(/\.[0-9a-z]+$/i));

const isLocation = (input?: Url | LocationType): input is LocationType =>
typeof input !== 'string';

export function Link({ href, search, hash, target, ...props }: LinkProps) {
if (isInternalTarget(target) && isRelative(href)) {
if (isInternalTarget(target) && isRelative(href) && !isDownload(href)) {
return (
<LinkComponent
href={overrideUrlParameters(href, search, hash)}
Expand Down

0 comments on commit ddc8e48

Please sign in to comment.