MCPcopy Index your code
hub / github.com/nodeSolidServer/node-solid-server / delete

Method delete

lib/ldp.mjs:496–526  ·  view source on GitHub ↗
(url)

Source from the content-addressed store, hash-verified

494 }
495
496 async delete (url) {
497 // First check if the path points to a valid file
498 let path, stats
499 try {
500 ({ path } = await this.resourceMapper.mapUrlToFile({ url }))
501 stats = await this.stat(path)
502 } catch (err) {
503 throw error(404, "Can't find " + err)
504 }
505
506 // delete aclCache
507 let aclUrl = typeof url !== 'string' ? this.resourceMapper.getRequestUrl(url) : url
508 aclUrl = aclUrl.endsWith(this.suffixAcl) ? aclUrl : aclUrl + this.suffixAcl
509 debug.handlers('DELETE ACL CACHE ' + aclUrl)
510 clearAclCache(aclUrl)
511
512 // If so, delete the directory or file
513 if (stats.isDirectory()) {
514 // DELETE method not allowed on podRoot
515 if ((url.url || url) === '/') {
516 throw error(405, 'DELETE of PodRoot is not allowed')
517 }
518 return this.deleteContainer(path)
519 } else {
520 // DELETE method not allowed on podRoot/.acl
521 if (['/' + this.suffixAcl, '/profile/card'].some(item => (url.url || url) === item)) {
522 throw error(405, `DELETE of ${url.url || url} is not allowed`)
523 }
524 return this.deleteDocument(path)
525 }
526 }
527
528 async deleteContainer (directory) {
529 if (directory[directory.length - 1] !== '/') directory += '/'

Callers 5

LdpMiddlewareFunction · 0.80
handlerFunction · 0.80
ldp-test.mjsFile · 0.80
acl-oidc-test.mjsFile · 0.80
http-test.mjsFile · 0.80

Calls 6

statMethod · 0.95
deleteContainerMethod · 0.95
deleteDocumentMethod · 0.95
clearAclCacheFunction · 0.90
mapUrlToFileMethod · 0.80
getRequestUrlMethod · 0.80

Tested by

no test coverage detected