Skip to content

Commit cc4e3a7

Browse files
author
Nicola Greco
committed
Merge pull request #94 from martinmr/post-fixes
Support for nquads and json-ld files and other minor fixes.
2 parents 9157b3d + e3e234f commit cc4e3a7

2 files changed

Lines changed: 5 additions & 13 deletions

File tree

‎handlers/get.js‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ function get(req, res, includeBody) {
9696

9797
// Consider acl and meta files text/turtle
9898
if (path.extname(filename) === options.suffixAcl ||
99-
path.basename(filename) === options.suffixAcl ||
99+
path.basename(filename) === turtleExtension ||
100100
path.basename(filename) === metaExtension) {
101101
contentType = 'text/turtle';
102102
}
@@ -136,7 +136,6 @@ function get(req, res, includeBody) {
136136
match,
137137
{ encoding: "utf8" });
138138

139-
//TODO integrate ACL
140139
if (S(match).endsWith(".ttl") && aclAllow(match)) {
141140
$rdf.parse(
142141
fileData,
@@ -203,7 +202,6 @@ function get(req, res, includeBody) {
203202
return res.status(500).send(err);
204203
}
205204

206-
//TODO rdflib callbacks
207205
$rdf.serialize(
208206
undefined,
209207
resourceGraph,

‎handlers/post.js‎

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -34,21 +34,17 @@ function handler(req, res) {
3434
// Error on invalid content-type
3535
if (contentType != 'text/turtle' &&
3636
contentType != 'text/n3' &&
37-
contentType != 'application/rdf+xml') {
38-
//TODO Handle json and nquad content types
37+
contentType != 'application/rdf+xml' &&
38+
contentType != 'application/json+ld' &&
39+
contentType != 'application/nquads' &&
40+
contentType != 'application/n-quads') {
3941
debug("POST -- Invalid Content Type: " + contentType);
4042
return res.status(415).send("Invalid Content Type");
4143
}
4244

4345

4446
var containerPath = file.uriToFilename(req.path, options.root);
4547
debug("POST -- Container path: " + containerPath);
46-
47-
// Container not found/invalid
48-
if (metadata.isMetadataFile(containerPath)) {
49-
debug("POST -- Invalid container.");
50-
return res.sendStatus(404);
51-
}
5248

5349
// Not a container
5450
if (containerPath[containerPath.length - 1] != '/') {
@@ -75,7 +71,6 @@ function handler(req, res) {
7571
}
7672

7773
var resourceGraph = $rdf.graph();
78-
// TODO make sure correct text is selected
7974
var requestText = req.convertedText || req.text;
8075
var uri = file.uriBase(req);
8176
var resourceBaseUri = file.filenameToBaseUri(
@@ -136,5 +131,4 @@ function handler(req, res) {
136131
}
137132
}
138133

139-
140134
exports.handler = handler;

0 commit comments

Comments
 (0)