diff --git a/History.md b/History.md index e2dfbc84d7..234671e5d6 100644 --- a/History.md +++ b/History.md @@ -5,6 +5,7 @@ unreleased * cleanup: remove AsyncLocalStorage check from tests * cleanup: remove unnecessary require for global Buffer * perf: use loop for acceptParams +* Replace `methods` dependency with standard library 5.0.1 / 2024-10-08 ========== diff --git a/lib/application.js b/lib/application.js index b19055ec82..ebef606bd3 100644 --- a/lib/application.js +++ b/lib/application.js @@ -14,10 +14,10 @@ */ var finalhandler = require('finalhandler'); -var methods = require('methods'); var debug = require('debug')('express:application'); var View = require('./view'); var http = require('http'); +var methods = require('./utils').methods; var compileETag = require('./utils').compileETag; var compileQueryParser = require('./utils').compileQueryParser; var compileTrust = require('./utils').compileTrust; diff --git a/lib/utils.js b/lib/utils.js index 0092629f17..d11f8aa168 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -12,6 +12,7 @@ * @api private */ +var { METHODS } = require('node:http'); var contentType = require('content-type'); var etag = require('etag'); var mime = require('mime-types') @@ -19,6 +20,12 @@ var proxyaddr = require('proxy-addr'); var qs = require('qs'); var querystring = require('querystring'); +/** + * A list of lowercased HTTP methods that are supported by Node.js. + * @api private + */ +exports.methods = METHODS.map((method) => method.toLowerCase()); + /** * Return strong ETag for `body`. * diff --git a/package.json b/package.json index 54b4bb5704..f42bbc4be5 100644 --- a/package.json +++ b/package.json @@ -47,7 +47,6 @@ "fresh": "2.0.0", "http-errors": "2.0.0", "merge-descriptors": "^2.0.0", - "methods": "~1.1.2", "mime-types": "^3.0.0", "on-finished": "2.4.1", "once": "1.4.0", diff --git a/test/Route.js b/test/Route.js index 2a37b9a483..a748ab7476 100644 --- a/test/Route.js +++ b/test/Route.js @@ -4,7 +4,7 @@ var after = require('after'); var assert = require('assert') var express = require('../') , Route = express.Route - , methods = require('methods') + , methods = require('../lib/utils').methods describe('Route', function(){ it('should work without handlers', function(done) { diff --git a/test/Router.js b/test/Router.js index a1952f445a..fcd48ab367 100644 --- a/test/Router.js +++ b/test/Router.js @@ -3,7 +3,7 @@ var after = require('after'); var express = require('../') , Router = express.Router - , methods = require('methods') + , methods = require('../lib/utils').methods , assert = require('assert'); describe('Router', function(){ diff --git a/test/app.router.js b/test/app.router.js index bdf4011a61..61b48eb4a3 100644 --- a/test/app.router.js +++ b/test/app.router.js @@ -4,7 +4,7 @@ var after = require('after'); var express = require('../') , request = require('supertest') , assert = require('assert') - , methods = require('methods'); + , methods = require('../lib/utils').methods; var shouldSkipQuery = require('./support/utils').shouldSkipQuery diff --git a/test/res.send.js b/test/res.send.js index 23ffd9305c..b061dfcc51 100644 --- a/test/res.send.js +++ b/test/res.send.js @@ -2,7 +2,7 @@ var assert = require('assert') var express = require('..'); -var methods = require('methods'); +var methods = require('../lib/utils').methods; var request = require('supertest'); var utils = require('./support/utils');