Skip to content
This repository has been archived by the owner on Oct 16, 2024. It is now read-only.

Commit

Permalink
Merge pull request #142 from owncloud/fix/more-resilient-getResourceType
Browse files Browse the repository at this point in the history
fix: Make webdavContext.getResourceType more resilient
  • Loading branch information
dschmidt authored Dec 6, 2023
2 parents 91c1812 + 836457b commit 7a9e181
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
## Changelog for [1.8.8] (2023-12-06)
The following sections list the changes for 1.8.8

[1.8.8]: https://github.com/owncloud/owncloud-test-middleware/compare/v1.8.7...v1.8.8

### Summary
- Make webdavContext.getResourceType more resilient @dschmidt in https://github.com/owncloud/owncloud-test-middleware/pull/142

## Changelog for [1.8.7] (2023-11-16)
The following sections list the changes for 1.8.7

Expand Down
16 changes: 12 additions & 4 deletions src/stepDefinitions/webdavContext.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,16 +49,24 @@ const fileShouldNotHaveContent = async function(userId, file, content) {
}

const getResourceType = function(data) {
let resourceType

const result = xml2js(data, { compact: true })
const responses = _.get(result, 'd:multistatus.d:response')
let response
if (responses instanceof Array) {
resourceType = _.get(responses[0], 'd:propstat.d:prop.d:resourcetype')
response = responses[0]
} else {
response = responses
}

const propstats = response['d:propstat']
let propstat
if (propstats instanceof Array) {
propstat = propstats[0]
} else {
resourceType = _.get(responses, 'd:propstat.d:prop.d:resourcetype')
propstat = propstats
}

const resourceType = _.get(propstat, 'd:prop.d:resourcetype')
if (Object.keys(resourceType)[0] === 'd:collection') {
return 'folder'
} else {
Expand Down

0 comments on commit 7a9e181

Please sign in to comment.