Skip to content

Commit

Permalink
Merge branch 'issue#1743' of https://github.com/solid/node-solid-server
Browse files Browse the repository at this point in the history
… into issue#1743
  • Loading branch information
bourgeoa committed Dec 27, 2023
2 parents 9e14a1d + a99473d commit 4900dc7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion lib/handlers/put.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ async function handler (req, res, next) {
res.header('MS-Author-Via', 'SPARQL')
const contentType = req.get('content-type')

// check if a folder or resource with same name exists
// check whether a folder or resource with same name exists
try {
const ldp = req.app.locals.ldp
await ldp.checkItemName(req)
Expand Down
8 changes: 4 additions & 4 deletions lib/ldp.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ class LDP {
extension = ''
}

// allways return a valid URL.
// always return a valid URL.
const resourceUrl = await ldp.getAvailableUrl(hostname, containerPath, { slug, extension, container })
debug.handlers('POST -- Will create at: ' + resourceUrl)

Expand Down Expand Up @@ -327,7 +327,7 @@ class LDP {
} catch (err) { }
}

// check if a document (or container) has the same name than a document (or container)
// check whether a document (or container) has the same name as another document (or container)
async checkItemName (url) {
let testName, testPath
const { hostname, pathname } = this.resourceMapper._parseUrl(url) // (url.url || url)
Expand Down Expand Up @@ -585,13 +585,13 @@ class LDP {

let itemName = slug.endsWith(extension) || slug.endsWith(this.suffixAcl) || slug.endsWith(this.suffixMeta) ? slug : slug + extension
try {
// check resource exists
// check whether resource exists
const context = container ? '/' : ''
await this.resourceMapper.mapUrlToFile({ url: (requestUrl + itemName + context) })
itemName = `${uuid.v1()}-${itemName}`
} catch (e) {
try {
// check resource with same name exists
// check whether resource with same name exists
const context = !container ? '/' : ''
await this.resourceMapper.mapUrlToFile({ url: (requestUrl + itemName + context) })
itemName = `${uuid.v1()}-${itemName}`
Expand Down

0 comments on commit 4900dc7

Please sign in to comment.