@@ -543,33 +543,25 @@ var Client = module.exports = function (config) {
543
543
var isUrlParam = url . indexOf ( ':' + paramName ) !== - 1
544
544
var valFormat = isUrlParam || format !== 'json' ? 'query' : format
545
545
var val
546
- if ( valFormat !== 'json' ) {
547
- if ( typeof msg [ paramName ] === 'object' ) {
548
- try {
549
- msg [ paramName ] = JSON . stringify ( msg [ paramName ] )
550
- val = encodeURIComponent ( msg [ paramName ] )
551
- } catch ( ex ) {
552
- return debug ( 'error:' , 'httpSend: Error while converting object to JSON: ' +
553
- ( ex . message || ex ) )
554
- }
555
- } else if ( def . params [ paramName ] && def . params [ paramName ] . combined ) {
556
- // Check if this is a combined (search) string.
546
+ if ( valFormat === 'json' ) {
547
+ val = msg [ paramName ]
548
+ } else {
549
+ if ( def . params [ paramName ] && def . params [ paramName ] . combined ) {
550
+ // Check if this is a combined (search) string.
557
551
val = msg [ paramName ] . split ( / [ \s \t \r \n ] * \+ [ \s \t \r \n ] * / )
558
- . map ( function ( part ) {
559
- return encodeURIComponent ( part )
560
- } )
561
- . join ( '+' )
552
+ . map ( function ( part ) {
553
+ return encodeURIComponent ( part )
554
+ } )
555
+ . join ( '+' )
562
556
} else {
563
- // the ref param is a path so we don't want to [fully] encode it but we do want to encode the # if there is one
564
- // (see https://github.com/mikedeboer/node-github/issues/499#issuecomment-280093040)
557
+ // the ref param is a path so we don't want to [fully] encode it but we do want to encode the # if there is one
558
+ // (see https://github.com/mikedeboer/node-github/issues/499#issuecomment-280093040)
565
559
if ( paramName === 'ref' ) {
566
560
val = msg [ paramName ] . replace ( / # / g, '%23' )
567
561
} else {
568
562
val = encodeURIComponent ( msg [ paramName ] )
569
563
}
570
564
}
571
- } else {
572
- val = msg [ paramName ]
573
565
}
574
566
575
567
if ( isUrlParam ) {
0 commit comments