Skip to content

Commit 8289aad

Browse files
author
Nicola Greco
committed
Merge pull request #65 from nicola/patch-fix
Fixing PATCH path when parsing
2 parents f5a63f6 + 5bfa7d7 commit 8289aad

2 files changed

Lines changed: 56 additions & 1 deletion

File tree

‎handlers/patch.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ function handler(req, res) {
1818
var filename = file.uriToFilename(req.path, options.base);
1919
var patchContentType = req.get('content-type').split(';')[0].trim(); // Ignore parameters
2020
var targetContentType = mime.lookup(filename);
21-
var targetURI = options.prePathSlash + req.path;
21+
var targetURI = file.uriAbs(req) + req.path;
2222
var patchURI = targetURI ; // @@@ beware the triples from the patch ending up in the same place
2323
debug("PATCH -- Content-type " + patchContentType + " patching target " + targetContentType + " <" + targetURI + '>');
2424
var targetKB = $rdf.graph();

‎test/patch.js‎

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
var ldnode = require('../');
2+
var supertest = require('supertest');
3+
var fs = require('fs');
4+
var fsExtra = require('fs-extra');
5+
var expect = require('chai').expect;
6+
var assert = require('chai').assert;
7+
var path = require('path');
8+
9+
function cp (src, dest) {
10+
return fsExtra.copySync(
11+
__dirname + '/' + src,
12+
__dirname + '/' + dest);
13+
}
14+
function read (file) {
15+
return fs.readFileSync(__dirname + '/' + file, {
16+
'encoding': 'utf8'
17+
});
18+
}
19+
function rm (file) {
20+
return fs.unlinkSync(__dirname + '/' + file);
21+
}
22+
23+
function write (text, file) {
24+
return fs.writeFileSync(__dirname + '/' + file, text);
25+
}
26+
27+
28+
describe('PATCH', function () {
29+
var ldp = ldnode.createServer({
30+
base: __dirname + '/testfiles',
31+
mount: '/test'
32+
});
33+
ldp.listen(3453);
34+
var server = supertest('http://localhost:3453/test');
35+
36+
describe('POST', function() {
37+
write(
38+
'<#current> <#temp> 123 .',
39+
'testfiles/emptyExample.ttl');
40+
41+
it('nothing should change with an empty file', function (done) {
42+
server.post('/emptyExample.ttl')
43+
.set('content-type', 'application/sparql-update')
44+
.send('')
45+
.end(function(err, res, body){
46+
assert.equal(
47+
read('testfiles/emptyExample.ttl'),
48+
'\n <#current> <#temp> 123 .\n');
49+
rm('testfiles/emptyExample.ttl');
50+
done(err);
51+
});
52+
});
53+
54+
});
55+
});

0 commit comments

Comments
 (0)