diff --git a/frontend/src/api/share.js b/frontend/src/api/share.js index 1ac4473a..bfc21d57 100644 --- a/frontend/src/api/share.js +++ b/frontend/src/api/share.js @@ -15,16 +15,37 @@ export async function remove(hash) { }); } -export async function create(url, password = "", expires = "", unit = "hours") { +export async function create( + config = { + url: "", + password: "", + expires: "", + unit: "hours", + custom: false, + customLink: "", + } +) { + let { + url, + password = "", + expires = "", + unit = "hours", + custom = false, + customLink = "", + } = config; url = removePrefix(url); url = `/api/share${url}`; if (expires !== "") { url += `?expires=${expires}&unit=${unit}`; } - let body = "{}"; - if (password != "" || expires !== "" || unit !== "hours") { - body = JSON.stringify({ password: password, expires: expires, unit: unit }); + let body = { + custom, + customLink: customLink, + }; + if (password !== "" || expires !== "" || unit !== "hours") { + Object.assign(body, { password: password, expires: expires, unit: unit }); } + body = JSON.stringify(body); return fetchJSON(url, { method: "POST", body: body, diff --git a/frontend/src/components/prompts/Share.vue b/frontend/src/components/prompts/Share.vue index 210b2f93..bc25f97e 100644 --- a/frontend/src/components/prompts/Share.vue +++ b/frontend/src/components/prompts/Share.vue @@ -68,6 +68,27 @@