Revert xml lib, to avoid unexpected issues
This commit is contained in:
@@ -12,7 +12,7 @@ export function addDavPrefixToKeys(object: Record<string, any>, prefix = 'D:'):
|
||||
|
||||
if (typeof object === 'object' && object !== null) {
|
||||
return Object.entries(object).reduce((reducedObject, [key, value]) => {
|
||||
const prefixedKey = key.startsWith('#') || key.startsWith('@') ? key : `${prefix}${key}`;
|
||||
const prefixedKey = key === 'xml' || key.startsWith('#') || key.startsWith('@') ? key : `${prefix}${key}`;
|
||||
reducedObject[prefixedKey] = addDavPrefixToKeys(value);
|
||||
return reducedObject;
|
||||
}, {} as Record<string, any>);
|
||||
@@ -105,8 +105,10 @@ export async function buildPropFindResponse(
|
||||
const filePaths = await getFilePaths(join(rootPath, queryPath), depth);
|
||||
|
||||
const response: Record<string, any> = {
|
||||
'@version': '1.0',
|
||||
'@encoding': 'UTF-8',
|
||||
xml: {
|
||||
'@version': '1.0',
|
||||
'@encoding': 'UTF-8',
|
||||
},
|
||||
multistatus: {
|
||||
'@xmlns:D': 'DAV:',
|
||||
response: [],
|
||||
|
||||
@@ -135,8 +135,10 @@ Deno.test('that @libs/xml.parse works', () => {
|
||||
</prop>
|
||||
</propfind>`,
|
||||
expected: {
|
||||
'@version': '1.0',
|
||||
'@encoding': 'UTF-8',
|
||||
xml: {
|
||||
'@version': 1,
|
||||
'@encoding': 'UTF-8',
|
||||
},
|
||||
propfind: {
|
||||
'@xmlns': 'DAV:',
|
||||
prop: {
|
||||
@@ -153,8 +155,10 @@ Deno.test('that @libs/xml.parse works', () => {
|
||||
</D:prop>
|
||||
</D:propfind>`,
|
||||
expected: {
|
||||
'@version': '1.0',
|
||||
'@encoding': 'UTF-8',
|
||||
xml: {
|
||||
'@version': 1,
|
||||
'@encoding': 'UTF-8',
|
||||
},
|
||||
'D:propfind': {
|
||||
'@xmlns:D': 'DAV:',
|
||||
'D:prop': {
|
||||
@@ -175,8 +179,10 @@ Deno.test('that @libs/xml.stringify works', () => {
|
||||
const tests: { input: Record<string, any>; expected: string }[] = [
|
||||
{
|
||||
input: {
|
||||
'@version': '1.0',
|
||||
'@encoding': 'UTF-8',
|
||||
xml: {
|
||||
'@version': '1.0',
|
||||
'@encoding': 'UTF-8',
|
||||
},
|
||||
'D:propfind': {
|
||||
'D:prop': {
|
||||
'D:displayname': 'test',
|
||||
@@ -192,8 +198,10 @@ Deno.test('that @libs/xml.stringify works', () => {
|
||||
},
|
||||
{
|
||||
input: {
|
||||
'@version': '1.0',
|
||||
'@encoding': 'UTF-8',
|
||||
xml: {
|
||||
'@version': '1.0',
|
||||
'@encoding': 'UTF-8',
|
||||
},
|
||||
'D:propfind': {
|
||||
'@xmlns:D': 'DAV:',
|
||||
'D:prop': {
|
||||
|
||||
Reference in New Issue
Block a user