@@ -68,47 +68,43 @@ module.exports = function (options) {
6868 var self = this ;
6969
7070 // construct query params
71- if ( opts . queryParams && this . source . queryString ) {
71+ if ( opts . queryParams ) {
7272 var queryStringKeys = Object . keys ( this . source . queryString ) ;
7373
74- if ( queryStringKeys . length ) {
75- queryStringKeys . map ( function ( name ) {
76- var value = self . source . queryString [ name ] ;
77-
78- if ( util . isArray ( value ) ) {
79- value . map ( function ( val ) {
80- code . push ( util . format ( '%s==%s' , name , val ) ) ;
81- } ) ;
82- } else {
83- code . push ( util . format ( '%s==%s' , name , value ) ) ;
84- }
85- } ) ;
86- }
87- }
74+ queryStringKeys . map ( function ( name ) {
75+ var value = self . source . queryString [ name ] ;
8876
89- // construct post params
90- if ( this . source . postData && ! this . source . postData . text && this . source . postData . params && this . source . postData . params . length ) {
91- this . source . postData . params . map ( function ( param ) {
92- code . push ( util . format ( '%s:%s' , param . name , param . value ) ) ;
77+ if ( util . isArray ( value ) ) {
78+ value . map ( function ( val ) {
79+ code . push ( util . format ( '%s==%s' , name , val ) ) ;
80+ } ) ;
81+ } else {
82+ code . push ( util . format ( '%s==%s' , name , value ) ) ;
83+ }
9384 } ) ;
9485 }
9586
9687 // construct headers
97- if ( this . source . headers && this . source . headers . length ) {
98- this . source . headers . map ( function ( header ) {
99- code . push ( util . format ( '%s:%s' , header . name , header . value ) ) ;
100- } ) ;
101- }
88+ this . source . headers . map ( function ( header ) {
89+ code . push ( util . format ( '%s:%s' , header . name , header . value ) ) ;
90+ } ) ;
10291
10392 // construct cookies argument
104- if ( this . source . cookies && this . source . cookies . length ) {
105- var cookies = this . source . cookies . map ( function ( cookie ) {
106- return encodeURIComponent ( cookie . name ) + '=' + encodeURIComponent ( cookie . value ) ;
107- } ) ;
93+ var cookies = this . source . cookies . map ( function ( cookie ) {
94+ return encodeURIComponent ( cookie . name ) + '=' + encodeURIComponent ( cookie . value ) ;
95+ } ) ;
10896
97+ if ( cookies . length ) {
10998 code . push ( util . format ( 'Cookie:%s' , cookies . join ( '; ' ) ) ) ;
11099 }
111100
101+ // construct post params
102+ if ( ! this . source . postData . text && this . source . postData . params && this . source . postData . params . length ) {
103+ this . source . postData . params . map ( function ( param ) {
104+ code . push ( util . format ( '%s:%s' , param . name , param . value ) ) ;
105+ } ) ;
106+ }
107+
112108 return code . join ( opts . indent !== false ? ' \\\n' + opts . indent : ' ' ) ;
113109} ;
114110
0 commit comments