diff --git a/lib/handlers/get.js b/lib/handlers/get.js
index 97cac626c..05cc60bb5 100644
--- a/lib/handlers/get.js
+++ b/lib/handlers/get.js
@@ -7,6 +7,7 @@ var $rdf = require('rdflib')
var S = require('string')
var async = require('async')
var Negotiator = require('negotiator')
+const url = require('url')
var debug = require('debug')('solid:get')
var debugGlob = require('debug')('solid:glob')
@@ -132,6 +133,7 @@ function globHandler (req, res, next) {
var root = !ldp.idp ? ldp.root : ldp.root + req.hostname + '/'
var filename = utils.uriToFilename(req.path, root)
var uri = utils.uriBase(req)
+ const requestUri = url.resolve(uri, req.path)
var globOptions = {
noext: true,
@@ -176,7 +178,7 @@ function globHandler (req, res, next) {
var data = $rdf.serialize(
undefined,
globGraph,
- null,
+ requestUri,
'text/turtle')
// TODO this should be added as a middleware in the routes
res.setHeader('Content-Type', 'text/turtle')
diff --git a/package.json b/package.json
index 914cc3996..3d3358732 100644
--- a/package.json
+++ b/package.json
@@ -56,7 +56,7 @@
"node-forge": "^0.6.38",
"nodemailer": "^3.1.4",
"nomnom": "^1.8.1",
- "rdflib": "^0.12.3",
+ "rdflib": "^0.15.0",
"recursive-readdir": "^2.1.0",
"request": "^2.72.0",
"rimraf": "^2.5.0",
diff --git a/test/http.js b/test/http.js
index 8306e11af..3840d1ab7 100644
--- a/test/http.js
+++ b/test/http.js
@@ -4,6 +4,7 @@ var li = require('li')
var ldnode = require('../index')
var rm = require('./test-utils').rm
var path = require('path')
+const rdf = require('rdflib')
var suffixAcl = '.acl'
var suffixMeta = '.meta'
@@ -288,7 +289,30 @@ describe('HTTP APIs', function () {
it('should have glob support', function (done) {
server.get('/sampleContainer/example*')
.expect('content-type', /text\/turtle/)
- .expect(200, done)
+ .expect(200)
+ .expect((res) => {
+ let kb = rdf.graph()
+ rdf.parse(res.text, kb, 'https://localhost/', 'text/turtle')
+
+ assert(kb.match(
+ rdf.namedNode('https://localhost/example1.ttl#this'),
+ rdf.namedNode('http://purl.org/dc/elements/1.1/title'),
+ rdf.literal('Test title')
+ ).length, 'Must contain a triple from example1.ttl')
+
+ assert(kb.match(
+ rdf.namedNode('http://example.org/stuff/1.0/a'),
+ rdf.namedNode('http://example.org/stuff/1.0/b'),
+ rdf.literal('apple')
+ ).length, 'Must contain a triple from example2.ttl')
+
+ assert(kb.match(
+ rdf.namedNode('http://example.org/stuff/1.0/a'),
+ rdf.namedNode('http://example.org/stuff/1.0/b'),
+ rdf.literal('The first line\nThe second line\n more')
+ ).length, 'Must contain a triple from example3.ttl')
+ })
+ .end(done)
})
it('should have set acl and describedBy Links for container',
function (done) {
diff --git a/test/patch-2.js b/test/patch-2.js
index 0b8bfda80..23476936b 100644
--- a/test/patch-2.js
+++ b/test/patch-2.js
@@ -38,7 +38,31 @@ describe('PATCH', function () {
describe('DELETE', function () {
it('reproduce index 1 bug from pad', function (done) {
- var expected = '@prefix dc: .\n@prefix meeting: .\n@prefix card: .\n@prefix xsd: .\n@prefix p: .\n@prefix in: .\n@prefix n: .\n@prefix flow: .\n@prefix ic: .\n@prefix ui: .\n\n<#this>\n dc:author\n card:i;\n dc:created\n "2016-10-25T15:44:42Z"^^xsd:dateTime;\n dc:title\n "Shared Notes";\n a p:Notepad;\n p:next\n <#id1477502276660>.\n in:this flow:participation <#id1477522707481>; meeting:sharedNotes <#this> .\n <#id1477502276660> dc:author card:i; n:content ""; p:next <#this> .\n<#id1477522707481>\n ic:dtstart\n "2016-10-26T22:58:27Z"^^xsd:dateTime;\n flow:participant\n card:i;\n ui:backgroundColor\n "#c1d0c8".\n'
+ var expected = `@prefix : .
+@prefix dc: .
+@prefix c: .
+@prefix n: .
+@prefix p: .
+@prefix ic: .
+@prefix XML: .
+@prefix flow: .
+@prefix ui: .
+@prefix ind: .
+@prefix mee: .
+
+:id1477502276660 dc:author c:i; n:content ""; p:next :this.
+
+:id1477522707481
+ ic:dtstart "2016-10-26T22:58:27Z"^^XML:dateTime;
+ flow:participant c:i;
+ ui:backgroundColor "#c1d0c8".
+:this
+ a p:Notepad;
+ dc:author c:i;
+ dc:created "2016-10-25T15:44:42Z"^^XML:dateTime;
+ dc:title "Shared Notes";
+ p:next :id1477502276660.
+ind:this flow:participation :id1477522707481; mee:sharedNotes :this.\n\n`
write(`\n\
@@ -109,10 +133,10 @@ describe('PATCH', function () {
.end(function (err, res, body) {
assert.equal(
read('sampleContainer/prefixSparql.ttl'),
+ '@prefix : .\n' +
'@prefix schema: .\n' +
- '@prefix profile: .\n' +
- '\n' +
- ' <#> profile:first_name "Timothy"; a schema:Person .\n')
+ '@prefix pro: .\n\n' +
+ ': a schema:Person; pro:first_name "Timothy".\n\n')
rm('sampleContainer/prefixSparql.ttl')
done(err)
})
@@ -131,9 +155,9 @@ describe('PATCH', function () {
.end(function (err, res, body) {
assert.equal(
read('sampleContainer/addingTriple.ttl'),
- '\n' +
- ' <#current> <#temp> 123 .\n' +
- ' <#test> <#hello> 456 .\n')
+ '@prefix : .\n\n' +
+ ':current :temp 123 .\n\n' +
+ ':test :hello 456 .\n\n')
rm('sampleContainer/addingTriple.ttl')
done(err)
})
@@ -150,8 +174,8 @@ describe('PATCH', function () {
.end(function (err, res, body) {
assert.equal(
read('sampleContainer/addingTripleValue.ttl'),
- '\n' +
- ' <#current> <#temp> 123, 456 .\n')
+ '@prefix : .\n\n' +
+ ':current :temp 123, 456 .\n\n')
rm('sampleContainer/addingTripleValue.ttl')
done(err)
})
@@ -168,8 +192,8 @@ describe('PATCH', function () {
.end(function (err, res, body) {
assert.equal(
read('sampleContainer/addingTripleSubj.ttl'),
- '\n' +
- ' <#current> <#temp2> 456; <#temp> 123 .\n')
+ '@prefix : .\n\n' +
+ ':current :temp 123; :temp2 456 .\n\n')
rm('sampleContainer/addingTripleSubj.ttl')
done(err)
})
@@ -187,8 +211,8 @@ describe('PATCH', function () {
.end(function (err, res, body) {
assert.equal(
read('sampleContainer/emptyExample.ttl'),
- '\n' +
- ' <#current> <#temp> 123 .\n')
+ '@prefix : .\n\n' +
+ ':current :temp 123 .\n\n')
rm('sampleContainer/emptyExample.ttl')
done(err)
})
diff --git a/test/patch.js b/test/patch.js
index 485161168..036544283 100644
--- a/test/patch.js
+++ b/test/patch.js
@@ -19,6 +19,7 @@ describe('PATCH', function () {
it('should create a new file if file does not exist', function (done) {
rm('sampleContainer/notExisting.ttl')
+
server.patch('/notExisting.ttl')
.set('content-type', 'application/sparql-update')
.send('INSERT DATA { :test :hello 456 .}')
@@ -26,7 +27,8 @@ describe('PATCH', function () {
.end(function (err, res, body) {
assert.equal(
read('sampleContainer/notExisting.ttl'),
- '\n <#test> <#hello> 456 .\n')
+ '@prefix : .\n\n' +
+ ':test :hello 456 .\n\n')
rm('sampleContainer/notExisting.ttl')
done(err)
})
@@ -44,7 +46,7 @@ describe('PATCH', function () {
.end(function (err, res, body) {
assert.equal(
read('sampleContainer/existingTriple.ttl'),
- '\n')
+ '@prefix : .\n\n')
rm('sampleContainer/existingTriple.ttl')
done(err)
})
@@ -72,10 +74,10 @@ describe('PATCH', function () {
.end(function (err, res, body) {
assert.equal(
read('sampleContainer/prefixSparql.ttl'),
+ '@prefix : .\n' +
'@prefix schema: .\n' +
- '@prefix profile: .\n' +
- '\n' +
- ' <#> profile:first_name "Timothy"; a schema:Person .\n')
+ '@prefix pro: .\n\n' +
+ ': a schema:Person; pro:first_name "Timothy".\n\n')
rm('sampleContainer/prefixSparql.ttl')
done(err)
})
@@ -94,9 +96,9 @@ describe('PATCH', function () {
.end(function (err, res, body) {
assert.equal(
read('sampleContainer/addingTriple.ttl'),
- '\n' +
- ' <#current> <#temp> 123 .\n' +
- ' <#test> <#hello> 456 .\n')
+ '@prefix : .\n\n' +
+ ':current :temp 123 .\n\n' +
+ ':test :hello 456 .\n\n')
rm('sampleContainer/addingTriple.ttl')
done(err)
})
@@ -113,8 +115,8 @@ describe('PATCH', function () {
.end(function (err, res, body) {
assert.equal(
read('sampleContainer/addingTripleValue.ttl'),
- '\n' +
- ' <#current> <#temp> 123, 456 .\n')
+ '@prefix : .\n\n' +
+ ':current :temp 123, 456 .\n\n')
rm('sampleContainer/addingTripleValue.ttl')
done(err)
})
@@ -131,8 +133,8 @@ describe('PATCH', function () {
.end(function (err, res, body) {
assert.equal(
read('sampleContainer/addingTripleSubj.ttl'),
- '\n' +
- ' <#current> <#temp2> 456; <#temp> 123 .\n')
+ '@prefix : .\n\n' +
+ ':current :temp 123; :temp2 456 .\n\n')
rm('sampleContainer/addingTripleSubj.ttl')
done(err)
})
@@ -150,8 +152,8 @@ describe('PATCH', function () {
.end(function (err, res, body) {
assert.equal(
read('sampleContainer/emptyExample.ttl'),
- '\n' +
- ' <#current> <#temp> 123 .\n')
+ '@prefix : .\n\n' +
+ ':current :temp 123 .\n\n')
rm('sampleContainer/emptyExample.ttl')
done(err)
})
diff --git a/test/resources/sampleContainer/example1.ttl b/test/resources/sampleContainer/example1.ttl
index c2a488461..84508d9b9 100644
--- a/test/resources/sampleContainer/example1.ttl
+++ b/test/resources/sampleContainer/example1.ttl
@@ -2,6 +2,8 @@
@prefix dc: .
@prefix ex: .
+<#this> dc:title "Test title" .
+
dc:title "RDF/XML Syntax Specification (Revised)" ;
ex:editor [
diff --git a/test/resources/sampleContainer/example2.ttl b/test/resources/sampleContainer/example2.ttl
index 8259de95d..622bd8483 100644
--- a/test/resources/sampleContainer/example2.ttl
+++ b/test/resources/sampleContainer/example2.ttl
@@ -1,7 +1,3 @@
@prefix : .
@prefix rdf: .
-:a :b
- [ rdf:first "apple";
- rdf:rest [ rdf:first "banana";
- rdf:rest rdf:nil ]
- ] .
+:a :b "apple" .