Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 9 additions & 10 deletions lib/ldp-container.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,14 @@ module.exports.addStats = addStats
module.exports.getMetadataGraph = getMetadataGraph
module.exports.readdir = readdir

var $rdf = require('rdflib')
var debug = require('./debug')
var error = require('./http-error')
var fs = require('fs')
var ns = require('solid-namespace')($rdf)
var S = require('string')
// var turtleExtension = '.ttl'
var mime = require('mime-types')
const url = require('url')
const $rdf = require('rdflib')
const debug = require('./debug')
const error = require('./http-error')
const fs = require('fs')
const ns = require('solid-namespace')($rdf)
const S = require('string')
const mime = require('mime-types')
const path = require('path')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👏


function addContainerStats (ldp, reqUri, filename, resourceGraph, next) {
ldp.stat(filename, function (err, containerStats) {
Expand All @@ -38,7 +37,7 @@ function addFile (ldp, resourceGraph, containerUri, reqUri, uri, container, file
return callback(null)
}

let filePath = url.resolve(container, file)
const filePath = path.join(container, file)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lol


// Get file stats
ldp.stat(filePath, function (err, stats) {
Expand Down
29 changes: 12 additions & 17 deletions test/integration/ldp-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -245,26 +245,21 @@ describe('LDP', function () {
})
})

it('should ldp:contains the same amount of files in dir', function (done) {
it('should ldp:contains the same files in dir', function (done) {
ldp.listContainer(path.join(__dirname, '../resources/sampleContainer/'), 'https://server.tld/resources/sampleContainer/', 'https://server.tld', '', 'text/turtle', function (err, data) {
if (err) done(err)
fs.readdir(path.join(__dirname, '../resources/sampleContainer/'), function (err, files) {
var graph = $rdf.graph()
$rdf.parse(
data,
graph,
'https://server.tld/sampleContainer',
'text/turtle')
fs.readdir(path.join(__dirname, '../resources/sampleContainer/'), function (err, expectedFiles) {
const graph = $rdf.graph()
$rdf.parse(data, graph, 'https://server.tld/sampleContainer', 'text/turtle')
const statements = graph.match(null, ns.ldp('contains'), null)
const files = statements
.map(s => s.object.value.replace(/.*\//, ''))
.map(decodeURIComponent)

var statements = graph.each(
undefined,
ns.ldp('contains'),
undefined)

assert.notEqual(graph.statements.length, 0)
assert.equal(statements.length, files.length)
assert.notOk(err)
done()
files.sort()
expectedFiles.sort()
assert.deepEqual(files, expectedFiles)
done(err)
})
})
})
Expand Down
Empty file.