Skip to content
Open
Show file tree
Hide file tree
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
5 changes: 3 additions & 2 deletions src/http-proxy-middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { verifyConfig } from './configuration';
import { Debug as debug } from './debug';
import { getPlugins } from './get-plugins';
import { getLogger } from './logger';
import { matchPathFilter } from './path-filter';
import { matchPathFilter,getUrlPathName } from './path-filter';
import * as PathRewriter from './path-rewriter';
import * as Router from './router';
import type { Filter, Logger, Options, RequestHandler } from './types';
Expand Down Expand Up @@ -175,7 +175,8 @@ export class HttpProxyMiddleware<TReq, TRes> {
// rewrite path
private applyPathRewrite = async (req: http.IncomingMessage, pathRewriter) => {
if (pathRewriter) {
const path = await pathRewriter(req.url, req);
const reqPath = getUrlPathName(req.url);
const path = await pathRewriter(reqPath, req);

if (typeof path === 'string') {
debug('pathRewrite new path: %s', req.url);
Expand Down
2 changes: 1 addition & 1 deletion src/path-filter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ function matchMultiPath(pathFilterList: string[], uri?: string) {
* @param {String} uri from req.url
* @return {String} RFC 3986 path
*/
function getUrlPathName(uri?: string) {
export function getUrlPathName(uri?: string) {
return uri && url.parse(uri).pathname;
}

Expand Down