Skip to content

Commit c79d27f

Browse files
Merge pull request #2 from Joshuajrodrigues/1-workersdevdavlist-not-works-correctly
1 workersdevdavlist not works correctly
2 parents 0db54d7 + 9c9c8e2 commit c79d27f

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "bookodav",
3-
"version": "1.1.0",
3+
"version": "1.1.1",
44
"private": true,
55
"scripts": {
66
"deploy": "wrangler deploy",

src/handlers.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,8 @@ export async function handleFileList(request, env, ctx) {
147147
console.log("MISS");
148148
// List objects in R2 with the correct prefix
149149
const objects = await env.MY_BUCKET.list({ prefix });
150-
150+
console.log(objects);
151+
151152
// Generate WebDAV XML response
152153
const xmlResponse = `
153154
<D:multistatus xmlns:D="DAV:">
@@ -165,7 +166,7 @@ export async function handleFileList(request, env, ctx) {
165166
.map(
166167
(obj) => `
167168
<D:response>
168-
<D:href>/${obj.key}</D:href>
169+
<D:href>/${encodeURIComponent(obj.key)}</D:href>
169170
<D:propstat>
170171
<D:prop>
171172
<D:resourcetype/> <!-- Empty for files -->

src/public/dash/list.html

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,10 @@ <h2>File List</h2>
9191

9292
// Create a table row for each file
9393
const row = document.createElement('tr');
94+
console.log("hrefhrefhrefhrefhrefhrefhrefhref",href);
95+
9496
row.innerHTML = `
95-
<td>${href.split('/').pop()}</td>
97+
<td>${decodeURIComponent(href.split('/').pop())}</td>
9698
<td>${formatBytes(size)}</td>
9799
<td>${new Date(lastModified).toLocaleString()}</td>
98100
<td><a href="${href}" download>Download</a></td>

0 commit comments

Comments
 (0)