File tree 1 file changed +4
-2
lines changed
packages/fern-docs/ui/src/mdx/components/download
1 file changed +4
-2
lines changed Original file line number Diff line number Diff line change
1
+ import { last } from "es-toolkit/array" ;
1
2
import React , { ComponentProps , PropsWithChildren } from "react" ;
2
3
import { FernLink } from "../../../components/FernLink" ;
3
4
import { Button } from "../button" ;
@@ -24,12 +25,13 @@ export function Download({
24
25
25
26
e . preventDefault ( ) ;
26
27
try {
27
- const response = await fetch ( src , { mode : "no-cors" } ) ;
28
+ const response = await fetch ( src ) ;
28
29
const blob = await response . blob ( ) ;
29
30
const blobUrl = URL . createObjectURL ( blob ) ;
30
31
const a = document . createElement ( "a" ) ;
31
32
a . href = blobUrl ;
32
- a . download = filename || "" ;
33
+ // if the filename is not provided, use the last part of the src
34
+ a . download = filename || last ( src . split ( "/" ) ) || "" ;
33
35
document . body . appendChild ( a ) ;
34
36
a . click ( ) ;
35
37
document . body . removeChild ( a ) ;
You can’t perform that action at this time.
0 commit comments