+13
-6
src/knot-client.js
+13
-6
src/knot-client.js
···
9
9
}
10
10
11
11
async getBlob(filename) {
12
-
const url = `https://${this.domain}/${this.ownerDid}/${
13
-
this.repoName
14
-
}/blob/${this.branch}/${trimLeadingSlash(filename)}`;
12
+
const params = new URLSearchParams({
13
+
repo: `${this.ownerDid}/${this.repoName}`,
14
+
path: trimLeadingSlash(filename),
15
+
ref: this.branch,
16
+
});
17
+
const url = `https://${this.domain}/xrpc/sh.tangled.repo.blob?${params}`;
15
18
console.log(`[KNOT CLIENT]: GET ${url}`);
16
19
const res = await fetch(url);
17
20
return await res.json();
18
21
}
19
22
20
23
async getRaw(filename) {
21
-
const url = `https://${this.domain}/${this.ownerDid}/${this.repoName}/raw/${
22
-
this.branch
23
-
}/${trimLeadingSlash(filename)}`;
24
+
const params = new URLSearchParams({
25
+
repo: `${this.ownerDid}/${this.repoName}`,
26
+
path: trimLeadingSlash(filename),
27
+
ref: this.branch,
28
+
raw: "true",
29
+
});
30
+
const url = `https://${this.domain}/xrpc/sh.tangled.repo.blob?${params}`;
24
31
console.log(`[KNOT CLIENT]: GET ${url}`);
25
32
const res = await fetch(url, {
26
33
responseType: "arraybuffer",
+2
-2
src/pages-service.js
+2
-2
src/pages-service.js
···
67
67
}
68
68
let content = null;
69
69
const blob = await this.client.getBlob(filename);
70
-
if (blob.is_binary) {
70
+
if (blob.isBinary) {
71
71
content = await this.client.getRaw(filename);
72
72
} else {
73
-
content = blob.contents;
73
+
content = blob.content;
74
74
}
75
75
if (this.fileCache && content) {
76
76
const contentSize = Buffer.isBuffer(content)