Skip to content

Commit

Permalink
Reducing a comparison
Browse files Browse the repository at this point in the history
  • Loading branch information
avoidwork committed Aug 26, 2018
1 parent a9e0ae9 commit d3b88bf
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions lib/utility.js
Original file line number Diff line number Diff line change
Expand Up @@ -516,7 +516,8 @@ function bootstrap (obj) {
function hypermedia (server, req, rep, headers) {
const collection = req.parsed.pathname,
links = [],
seen = new Set();
seen = new Set(),
exists = rep !== null;
let query, page, page_size, nth, root, proot, parent;

// Parsing the object for hypermedia properties
Expand Down Expand Up @@ -582,7 +583,7 @@ function hypermedia (server, req, rep, headers) {
}
}

if (rep !== null) {
if (exists) {
if (Array.isArray(rep.data)) {
if (req.method === "GET" && (rep.status >= 200 && rep.status <= 206)) {
if (isNaN(page) || page <= 0) {
Expand Down Expand Up @@ -656,7 +657,7 @@ function hypermedia (server, req, rep, headers) {

headers.link = keysort(links, "rel, uri").map(i => `<${i.uri}>; rel="${i.rel}"`).join(", ");

if (rep !== null && rep.links !== void 0) {
if (exists && rep.links !== void 0) {
rep.links = links;
}
}
Expand Down

0 comments on commit d3b88bf

Please sign in to comment.