MCPcopy
hub / github.com/filebrowser/filebrowser / fetch

Function fetch

frontend/src/api/pub.ts:4–33  ·  view source on GitHub ↗
(url: string, password: string = "")

Source from the content-addressed store, hash-verified

2import { baseURL } from "@/utils/constants";
3
4export async function fetch(url: string, password: string = "") {
5 url = removePrefix(url);
6
7 const res = await fetchURL(
8 `/api/public/share${url}`,
9 {
10 headers: { "X-SHARE-PASSWORD": encodeURIComponent(password) },
11 },
12 false
13 );
14
15 const data = (await res.json()) as Resource;
16 data.url = `/share${url}`;
17
18 if (data.isDir) {
19 if (!data.url.endsWith("/")) data.url += "/";
20 data.items = data.items.map((item: any, index: any) => {
21 item.index = index;
22 item.url = `${data.url}${encodeURIComponent(item.name)}`;
23
24 if (item.isDir) {
25 item.url += "/";
26 }
27
28 return item;
29 });
30 }
31
32 return data;
33}
34
35export function download(
36 format: DownloadFormat,

Callers 4

fetchURLFunction · 0.70
loginFunction · 0.50
renewFunction · 0.50
signupFunction · 0.50

Calls 2

removePrefixFunction · 0.90
fetchURLFunction · 0.90

Tested by

no test coverage detected