Fix resource path handling in fuck windows
This commit is contained in:
parent
57ecaf6c0e
commit
66054ba062
25
src/index.ts
25
src/index.ts
@ -281,10 +281,16 @@ export default {
|
||||
break;
|
||||
}
|
||||
|
||||
let object = await bucket.get(resource_path);
|
||||
if (object === null && !resource_path.endsWith('/')) {
|
||||
let object = await bucket.head(resource_path);
|
||||
if (object === null && resource_path.endsWith('/')) {
|
||||
object = await bucket.head(resource_path.slice(0, -1));
|
||||
}
|
||||
|
||||
if (object === null) {
|
||||
response = new Response('Not Found', { status: 404 });
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
|
||||
let page = `<?xml version="1.0" encoding="utf-8"?>
|
||||
<multistatus xmlns="DAV:">
|
||||
<response>
|
||||
@ -309,7 +315,6 @@ export default {
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
break;
|
||||
case '1': {
|
||||
let page = `<?xml version="1.0" encoding="utf-8"?>
|
||||
@ -324,6 +329,18 @@ export default {
|
||||
include: ['httpMetadata', 'customMetadata'],
|
||||
});
|
||||
|
||||
if (r2_objects.objects.length === 1) {
|
||||
let object = r2_objects.objects[0];
|
||||
// When the resource is a collection
|
||||
if (object.key === resource_path && object.customMetadata?.resourcetype === '<collection />') {
|
||||
resource_path = resource_path.endsWith('/') ? resource_path : resource_path + '/';
|
||||
if (r2_objects.truncated) {
|
||||
delete r2_objects.cursor
|
||||
}
|
||||
r2_objects.truncated = true;
|
||||
}
|
||||
}
|
||||
|
||||
for (let object of r2_objects.objects.filter(object => object.key !== resource_path)) {
|
||||
page += `
|
||||
<response>
|
||||
|
Loading…
Reference in New Issue
Block a user