Skip to content

Commit

Permalink
Fixing hypermedia()
Browse files Browse the repository at this point in the history
  • Loading branch information
avoidwork committed Nov 19, 2016
1 parent 36ffb7c commit cc77fae
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
21 changes: 11 additions & 10 deletions lib/utility.js
Original file line number Diff line number Diff line change
Expand Up @@ -667,19 +667,20 @@ function hypermedia (server, req, rep, headers) {
}

array.each(rep.data, i => {
var li = i.toString(),
uri;

if (li !== collection) {
uri = li.indexOf("//") > -1 || li.indexOf("/") === 0 ? li : (collection + "/" + li).replace(/^\/\//, "/");

if (server.allowed("GET", uri, req.host)) {
rep.links.push({uri: uri, rel: "item"});
}
}
let li, uri;

if (i instanceof Object) {
marshal(i, "item", req.parsed.pathname.replace(regex.trailing_slash, "").replace(regex.leading, ""));
} else {
li = i.toString();

if (li !== collection) {
uri = li.indexOf("//") > -1 || li.indexOf("/") === 0 ? li : (collection + "/" + li).replace(/^\/\//, "/");

if (server.allowed("GET", uri, req.host)) {
rep.links.push({uri: uri, rel: "item"});
}
}
}
});
} else if (rep.data instanceof Object) {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "tenso",
"description": "Tensō is an elastic REST API gateway for node.js",
"version": "4.0.5",
"version": "4.0.6",
"homepage": "http://avoidwork.github.io/tenso",
"author": "Jason Mulligan <[email protected]>",
"repository": {
Expand Down

0 comments on commit cc77fae

Please sign in to comment.