( url: string, password = "", expires = "", unit = "hours" )
| 16 | } |
| 17 | |
| 18 | export async function create( |
| 19 | url: string, |
| 20 | password = "", |
| 21 | expires = "", |
| 22 | unit = "hours" |
| 23 | ) { |
| 24 | url = removePrefix(url); |
| 25 | url = `/api/share${url}`; |
| 26 | if (expires !== "") { |
| 27 | url += `?expires=${expires}&unit=${unit}`; |
| 28 | } |
| 29 | let body = "{}"; |
| 30 | if (password != "" || expires !== "" || unit !== "hours") { |
| 31 | body = JSON.stringify({ |
| 32 | password: password, |
| 33 | expires: expires.toString(), // backend expects string not number |
| 34 | unit: unit, |
| 35 | }); |
| 36 | } |
| 37 | return fetchJSON(url, { |
| 38 | method: "POST", |
| 39 | body: body, |
| 40 | }); |
| 41 | } |
| 42 | |
| 43 | export function getShareURL(share: Share) { |
| 44 | return createURL("share/" + share.hash, {}); |
nothing calls this directly
no test coverage detected