MCPcopy Create free account
hub / github.com/vercel/vercel / applyRequestTransforms

Function applyRequestTransforms

packages/cli/src/util/dev/transforms.ts:58–78  ·  view source on GitHub ↗
(
  req: { url?: string; headers: IncomingHttpHeaders },
  transforms: Transform[]
)

Source from the content-addressed store, hash-verified

56
57/** Apply request-side transforms. */
58export function applyRequestTransforms(
59 req: { url?: string; headers: IncomingHttpHeaders },
60 transforms: Transform[]
61): void {
62 if (transforms.length === 0) {
63 return;
64 }
65
66 applyRequestHeaderTransforms(req.headers, transforms);
67
68 const parsed = url.parse(req.url || '/');
69 const query = parseQueryString(parsed.search);
70 applyQueryTransforms(query, transforms);
71
72 const newPath = getRequestPath(transforms);
73 if (newPath !== undefined) {
74 parsed.pathname = newPath;
75 }
76 parsed.search = formatQueryString(query);
77 req.url = url.format(parsed);
78}
79
80/** Whether any transform rules to be applied for responses. */
81export function hasResponseTransforms(transforms: Transform[]): boolean {

Callers 3

transforms.test.tsFile · 0.90
prepareTransformsMethod · 0.90
DevServerClass · 0.90

Calls 7

parseQueryStringFunction · 0.90
formatQueryStringFunction · 0.90
applyQueryTransformsFunction · 0.85
getRequestPathFunction · 0.85
formatMethod · 0.80
parseMethod · 0.45

Tested by

no test coverage detected