Skip to content

Commit

Permalink
Include async functions in origins promise detection
Browse files Browse the repository at this point in the history
  • Loading branch information
oshoemaker committed Dec 20, 2019
1 parent 71c4d00 commit faf4415
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ module.exports = function(options) {
let origin;
if (typeof options.origin === 'function') {
origin = options.origin(ctx);
if (origin instanceof Promise) origin = await origin;
const isAsync = origin.constructor.name === "AsyncFunction";
if (origin instanceof Promise || isAsync) origin = await origin;
if (!origin) return await next();
} else {
origin = options.origin || requestOrigin;
Expand Down

0 comments on commit faf4415

Please sign in to comment.