Skip to content

Commit

Permalink
Fixing OPTIONS route handling, removing an unneeded closure, upgradin…
Browse files Browse the repository at this point in the history
…g router
  • Loading branch information
avoidwork committed Jul 24, 2018
1 parent 4eca313 commit 5da89ae
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion lib/middleware.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ function payload (req, res, next) {
function keymaster (req, res) {
// No authentication, or it's already happened
if (req.protect === false || req.protectAsync === false || (req.session !== void 0 && req.isAuthenticated() === true) === true) {
const method = regex.getRewrite.test(req.method) ? "get" : req.method.toLowerCase(),
const method = regex.head.test(req.method) ? "get" : req.method.toLowerCase(),
routes = req.server.router.middleware.get(method.toUpperCase()) || new Map(),
uri = req.parsed.pathname;
let result;
Expand Down
6 changes: 3 additions & 3 deletions lib/utility.js
Original file line number Diff line number Diff line change
Expand Up @@ -502,7 +502,7 @@ function bootstrap (obj) {
} else {
each(Object.keys(routes), i => {
if (typeof routes[i] === "function") {
obj[method](i, (...args) => routes[i](...args));
obj[method](i, routes[i]);
} else {
obj[method](i, (req, res) => res.send(routes[i]));
}
Expand Down Expand Up @@ -546,7 +546,7 @@ function hypermedia (server, req, rep, headers) {
if (uri !== root && seen.has(uri) === false) {
seen.add(uri);

if (server.allowed("GET", uri, req.host) === true) {
if (server.allowed("GET", uri) === true) {
links.push({uri: uri, rel: lrel});
}
}
Expand Down Expand Up @@ -626,7 +626,7 @@ function hypermedia (server, req, rep, headers) {
if (li !== collection) {
const uri = li.indexOf("//") > -1 || li.indexOf("/") === 0 ? li : `${collection}/${li}`.replace(/^\/\//, "/");

if (server.allowed("GET", uri, req.host)) {
if (server.allowed("GET", uri)) {
links.push({uri: uri, rel: "item"});
}
}
Expand Down
8 changes: 4 additions & 4 deletions package-lock.json

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

4 changes: 2 additions & 2 deletions 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": "8.0.12",
"version": "8.0.13",
"homepage": "http://avoidwork.github.io/tenso",
"author": "Jason Mulligan <[email protected]>",
"repository": {
Expand Down Expand Up @@ -46,7 +46,7 @@
"tiny-uuid4": "^1.0.1",
"tiny-xml": "^1.0.6",
"uws": "^10.148.1",
"woodland": "^7.2.1",
"woodland": "^7.2.2",
"yamljs": "^0.3.0"
},
"devDependencies": {
Expand Down

0 comments on commit 5da89ae

Please sign in to comment.