Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: undefined property in unmatched host #178

Merged
merged 1 commit into from
Aug 15, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
const methods = require('methods');
const { pathToRegexp } = require('path-to-regexp');
const Layer = require('./layer');
const debug = require('debug')('koa-router');

Check warning on line 13 in lib/router.js

View workflow job for this annotation

GitHub Actions / Node 14 on ubuntu-latest

`debug` import should occur before import of `./layer`

Check warning on line 13 in lib/router.js

View workflow job for this annotation

GitHub Actions / Node 16 on ubuntu-latest

`debug` import should occur before import of `./layer`

Check warning on line 13 in lib/router.js

View workflow job for this annotation

GitHub Actions / Node 18 on ubuntu-latest

`debug` import should occur before import of `./layer`

/**
* @module koa-router
Expand Down Expand Up @@ -209,10 +209,10 @@
*/

for (const method_ of methods) {
function setMethodVerb(method) {

Check warning on line 212 in lib/router.js

View workflow job for this annotation

GitHub Actions / Node 14 on ubuntu-latest

Move function declaration to program root.

Check warning on line 212 in lib/router.js

View workflow job for this annotation

GitHub Actions / Node 16 on ubuntu-latest

Move function declaration to program root.

Check warning on line 212 in lib/router.js

View workflow job for this annotation

GitHub Actions / Node 18 on ubuntu-latest

Move function declaration to program root.
Router.prototype[method] = function (name, path, middleware) {
if (typeof path === 'string' || path instanceof RegExp) {
middleware = Array.prototype.slice.call(arguments, 2);

Check warning on line 215 in lib/router.js

View workflow job for this annotation

GitHub Actions / Node 14 on ubuntu-latest

Use the rest parameters instead of 'arguments'.

Check warning on line 215 in lib/router.js

View workflow job for this annotation

GitHub Actions / Node 16 on ubuntu-latest

Use the rest parameters instead of 'arguments'.

Check warning on line 215 in lib/router.js

View workflow job for this annotation

GitHub Actions / Node 18 on ubuntu-latest

Use the rest parameters instead of 'arguments'.
} else {
middleware = Array.prototype.slice.call(arguments, 1);
path = name;
Expand Down Expand Up @@ -483,7 +483,7 @@
return next().then(function () {
const allowed = {};

if (!ctx.status || ctx.status === 404) {
if (ctx.matched && (!ctx.status || ctx.status === 404)) {
for (let i = 0; i < ctx.matched.length; i++) {
const route = ctx.matched[i];
for (let j = 0; j < route.methods.length; j++) {
Expand Down
Loading