Skip to content

Commit 58178ca

Browse files
committedNov 29, 2017
chore: remove unused code
This is code from the ajax.org origin. There is only one parameter of type Object which is "file", and file is not a query parameter, so this code is never reached
1 parent b4482e6 commit 58178ca

File tree

1 file changed

+11
-19
lines changed

1 file changed

+11
-19
lines changed
 

‎lib/index.js

+11-19
Original file line numberDiff line numberDiff line change
@@ -543,33 +543,25 @@ var Client = module.exports = function (config) {
543543
var isUrlParam = url.indexOf(':' + paramName) !== -1
544544
var valFormat = isUrlParam || format !== 'json' ? 'query' : format
545545
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.
557551
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('+')
562556
} 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)
565559
if (paramName === 'ref') {
566560
val = msg[paramName].replace(/#/g, '%23')
567561
} else {
568562
val = encodeURIComponent(msg[paramName])
569563
}
570564
}
571-
} else {
572-
val = msg[paramName]
573565
}
574566

575567
if (isUrlParam) {

0 commit comments

Comments
 (0)
Please sign in to comment.