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;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
let object = await bucket.get(resource_path);
|
let object = await bucket.head(resource_path);
|
||||||
if (object === null && !resource_path.endsWith('/')) {
|
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 });
|
response = new Response('Not Found', { status: 404 });
|
||||||
} else {
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
let page = `<?xml version="1.0" encoding="utf-8"?>
|
let page = `<?xml version="1.0" encoding="utf-8"?>
|
||||||
<multistatus xmlns="DAV:">
|
<multistatus xmlns="DAV:">
|
||||||
<response>
|
<response>
|
||||||
@ -309,7 +315,6 @@ export default {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case '1': {
|
case '1': {
|
||||||
let page = `<?xml version="1.0" encoding="utf-8"?>
|
let page = `<?xml version="1.0" encoding="utf-8"?>
|
||||||
@ -324,6 +329,18 @@ export default {
|
|||||||
include: ['httpMetadata', 'customMetadata'],
|
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)) {
|
for (let object of r2_objects.objects.filter(object => object.key !== resource_path)) {
|
||||||
page += `
|
page += `
|
||||||
<response>
|
<response>
|
||||||
|
Loading…
Reference in New Issue
Block a user