refactor: correct type error in useDownloadResponse
This commit is contained in:
@@ -1,3 +1,6 @@
|
|||||||
|
import * as S from "fp-ts/string"
|
||||||
|
import * as RNEA from "fp-ts/ReadonlyNonEmptyArray"
|
||||||
|
import { pipe } from "fp-ts/function"
|
||||||
import { Ref, ref } from "@nuxtjs/composition-api"
|
import { Ref, ref } from "@nuxtjs/composition-api"
|
||||||
import { useI18n, useToast } from "~/helpers/utils/composables"
|
import { useI18n, useToast } from "~/helpers/utils/composables"
|
||||||
|
|
||||||
@@ -20,8 +23,18 @@ export default function useDownloadResponse(
|
|||||||
const a = document.createElement("a")
|
const a = document.createElement("a")
|
||||||
const url = URL.createObjectURL(file)
|
const url = URL.createObjectURL(file)
|
||||||
a.href = url
|
a.href = url
|
||||||
// TODO get uri from meta
|
|
||||||
a.download = `${url.split("/").pop().split("#")[0].split("?")[0]}`
|
// TODO: get uri from meta
|
||||||
|
a.download = pipe(
|
||||||
|
url,
|
||||||
|
S.split("/"),
|
||||||
|
RNEA.last,
|
||||||
|
S.split("#"),
|
||||||
|
RNEA.head,
|
||||||
|
S.split("?"),
|
||||||
|
RNEA.head
|
||||||
|
)
|
||||||
|
|
||||||
document.body.appendChild(a)
|
document.body.appendChild(a)
|
||||||
a.click()
|
a.click()
|
||||||
downloadIcon.value = "check"
|
downloadIcon.value = "check"
|
||||||
|
|||||||
Reference in New Issue
Block a user