@@ -4,6 +4,7 @@ import type { OpenAPIV2 } from "openapi-types";
44import type Router from "find-my-way" ;
55import { get } from "lodash-es" ;
66import qs from "qs" ;
7+ import querystring from "node:querystring" ;
78import multipart from "parse-multipart-data" ;
89
910import type { Interaction } from "../documents/pact" ;
@@ -15,6 +16,7 @@ import {
1516 formatSchemaPath ,
1617} from "../results/index" ;
1718import { minimumSchema , transformRequestSchema } from "../transform/index" ;
19+ import { config } from "../utils/config" ;
1820import { isValidRequest } from "../utils/interaction" ;
1921import { dereferenceOas , splitPath } from "../utils/schema" ;
2022import { getValidateFunction } from "../utils/validation" ;
@@ -25,11 +27,12 @@ const parseBody = (body: unknown, contentType: string) => {
2527 contentType . includes ( "application/x-www-form-urlencoded" ) &&
2628 typeof body === "string"
2729 ) {
28- return qs . parse ( body as string , {
29- allowDots : true ,
30- comma : true ,
31- depth : process . env . QUIRKS ? 0 : undefined ,
32- } ) ;
30+ return config . get ( "legacyParser" )
31+ ? querystring . parse ( body as string )
32+ : qs . parse ( body as string , {
33+ allowDots : true ,
34+ comma : true ,
35+ } ) ;
3336 }
3437
3538 if ( contentType . includes ( "multipart/form-data" ) && typeof body === "string" ) {
@@ -60,7 +63,7 @@ const canValidate = (contentType: string): boolean => {
6063 [
6164 "application/json" ,
6265 "application/x-www-form-urlencoded" ,
63- process . env . QUIRKS ? "" : "multipart/form-data" ,
66+ config . get ( "disableMultipartFormdata" ) ? "" : "multipart/form-data" ,
6467 ] . filter ( Boolean ) ,
6568 ) ;
6669} ;
@@ -110,7 +113,7 @@ export function* compareReqBody(
110113 schema &&
111114 canValidate ( contentType ) &&
112115 isValidRequest ( interaction ) &&
113- ( process . env . QUIRKS
116+ ( config . get ( "noValidateRequestBodyUnlessApplicationJson" )
114117 ? ! ! findMatchingType ( "application/json" , availableRequestContentTypes )
115118 : true )
116119 ) {
@@ -147,7 +150,7 @@ export function* compareReqBody(
147150 ! ! body &&
148151 ! schema &&
149152 isValidRequest ( interaction ) &&
150- ( process . env . QUIRKS
153+ ( config . get ( "noValidateRequestBodyUnlessApplicationJson" )
151154 ? ! ! findMatchingType ( "application/json" , availableRequestContentTypes ) ||
152155 availableRequestContentTypes . length === 0
153156 : true )
0 commit comments