Skip to content

Commit

Permalink
fix: adapt webdav client
Browse files Browse the repository at this point in the history
  • Loading branch information
reruin committed Jan 5, 2022
1 parent 7bea40a commit 41b2706
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions packages/sharelist-webdav/src/operations/propfind.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,14 @@ const propParse = (data: any) => {
*/

const convData = (files: Array<any>, options: any) => {
const { path, base = '', prop, ns: { prefix, uri } } = options
const { path, base = '', depth, prop, ns: { prefix, uri } } = options

return files.map((file: any) => {
const item: Record<string, any> = {}
for (const key of prop) {
if (key == 'displayname') {
item[key] = file.name.replace(/&/g, '&amp;').replace(/\</g, '&lt;')
} else if (key == 'getcontentlength') {
item[key] = file.name.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&apos;");

if (key == 'getcontentlength') {
item[key] = parseInt(file.size || 0)
} else if (key == 'resourcetype') {
item[key] = file.type == 'folder' ? { collection: '' } : ''
Expand All @@ -63,7 +63,7 @@ const convData = (files: Array<any>, options: any) => {
}
}

const href = ((base + path + '/' + encodeURIComponent(file.name))).replace(/\/{2,}/g, '/')
const href = (base + path + (depth == '0' ? '' : ('/' + encodeURIComponent(file.name)))).replace(/\/{2,}/g, '/')
//if (file.type == 'file' && file.download_url) href = file.download_url
return {
href,
Expand Down

0 comments on commit 41b2706

Please sign in to comment.