diff --git a/lib/express/mock-request.js b/lib/express/mock-request.js index 57b28f7..8128399 100644 --- a/lib/express/mock-request.js +++ b/lib/express/mock-request.js @@ -1,7 +1,6 @@ const accepts = require('accepts'); const typeis = require('type-is'); const parseRange = require('range-parser'); -const parse = require('parseurl'); const { isIP } = require('net'); const fresh = require('fresh'); @@ -119,7 +118,7 @@ defineGetter(req, 'subdomains', function subdomains() { }); defineGetter(req, 'path', function path() { - return parse(this).pathname; + return new URL(this.url, `${this.protocol || 'http'}://${this.hostname || 'localhost'}`).pathname; }); defineGetter(req, 'hostname', function hostname() { diff --git a/package-lock.json b/package-lock.json index af57d35..06b1f2f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -16,7 +16,6 @@ "merge-descriptors": "^1.0.1", "methods": "^1.1.2", "mime": "^1.3.4", - "parseurl": "^1.3.3", "range-parser": "^1.2.0", "type-is": "^1.6.18" }, @@ -4890,14 +4889,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/parseurl": { - "version": "1.3.3", - "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz", - "integrity": "sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ==", - "engines": { - "node": ">= 0.8" - } - }, "node_modules/path-exists": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", @@ -9919,11 +9910,6 @@ "lines-and-columns": "^1.1.6" } }, - "parseurl": { - "version": "1.3.3", - "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz", - "integrity": "sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ==" - }, "path-exists": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", diff --git a/package.json b/package.json index 4474771..cf12e87 100644 --- a/package.json +++ b/package.json @@ -53,7 +53,6 @@ "merge-descriptors": "^1.0.1", "methods": "^1.1.2", "mime": "^1.3.4", - "parseurl": "^1.3.3", "range-parser": "^1.2.0", "type-is": "^1.6.18" }, diff --git a/test/lib/http-mock.test-d.ts b/test/lib/http-mock.test-d.ts index cd34c45..cc0baaa 100644 --- a/test/lib/http-mock.test-d.ts +++ b/test/lib/http-mock.test-d.ts @@ -1,7 +1,7 @@ import { IncomingMessage as NodeRequest, OutgoingMessage as NodeResponse } from 'http'; // eslint-disable-next-line import/no-unresolved import { expectAssignable, expectNotAssignable, expectNotType, expectType } from 'tsd'; -// eslint-disable-next-line import/no-unresolved +// eslint-disable-next-line import/no-unresolved, import/no-extraneous-dependencies import { Request as ExpressRequest, Response as ExpressResponse } from 'express'; import { createMocks, createRequest, createResponse, MockRequest, MockResponse, Mocks } from '../../lib/http-mock';