Skip to content

Commit

Permalink
Respecting link header passed to hypermedia()
Browse files Browse the repository at this point in the history
  • Loading branch information
avoidwork committed Jan 2, 2017
1 parent 35fa9da commit 9029ce9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
9 changes: 9 additions & 0 deletions lib/utility.js
Original file line number Diff line number Diff line change
Expand Up @@ -727,6 +727,15 @@ function hypermedia (server, req, rep, headers) {
}

if (rep.links.length > 0) {
if (headers.link) {
headers.link.split('" <').forEach(i => {
rep.links.push({
uri: i.replace(/(^\<|\>.*$)/g, ""),
rel: i.replace(/(^.*rel\=\"|\"$)/g, "")
});
});
}

headers.link = keysort(rep.links, "rel, uri").map(i => {
return "<" + i.uri + ">; rel=\"" + i.rel + "\"";
}).join(", ");
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.3.3",
"version": "4.3.4",
"homepage": "http://avoidwork.github.io/tenso",
"author": "Jason Mulligan <[email protected]>",
"repository": {
Expand Down

0 comments on commit 9029ce9

Please sign in to comment.