Skip to content

Commit

Permalink
Removing regex.id which changes hypermedia ID linking (not consider…
Browse files Browse the repository at this point in the history
…ing major change because DB models default to lower case)
  • Loading branch information
avoidwork committed Jan 13, 2019
1 parent ee47a57 commit d67dfbe
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 5 deletions.
1 change: 0 additions & 1 deletion lib/regex.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ module.exports = {
collection: /(.*)(\/.*)$/,
hasParam: /\/:\w*/,
hypermedia: /(([a-z]+(_)?)?id|url|uri)$/i,
id: /^_?id$/i,
leading: /.*\//,
leftBrace: /\(/,
mimetype: /;.*/,
Expand Down
8 changes: 6 additions & 2 deletions lib/utility.js
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,10 @@ function bootstrap (obj) {
return obj;
}

function id (arg) {
return arg === "id" || arg === "_id";
}

function hypermedia (server, req, rep, headers) {
const collection = req.parsed.pathname,
links = [],
Expand All @@ -485,8 +489,8 @@ function hypermedia (server, req, rep, headers) {
let lcollection, uri;

// If ID like keys are found, and are not URIs, they are assumed to be root collections
if (regex.id.test(i) || regex.hypermedia.test(i)) {
if (regex.id.test(i) === false) {
if (id(i) || regex.hypermedia.test(i)) {
if (id(i) === false) {
lcollection = i.replace(regex.trailing, "").replace(regex.trailingS, "").replace(regex.trailingY, "ie") + "s";
lrel = "related";
} else {
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

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 HTTP/HTTP2 REST API framework",
"version": "10.0.34",
"version": "10.0.35",
"homepage": "http://avoidwork.github.io/tenso",
"author": "Jason Mulligan <[email protected]>",
"repository": {
Expand Down

0 comments on commit d67dfbe

Please sign in to comment.