@@ -402,19 +402,22 @@ class SmartApp {
402
402
* @param {* } response
403
403
*/
404
404
async handleHttpCallback ( request , response ) {
405
- if ( request . body && request . body . lifecycle === 'PING' ) {
406
- return this . _handleCallback ( request . body , responders . httpResponder ( response , this . _log ) )
405
+ const { body, originalUrl } = request
406
+
407
+ if ( body && body . lifecycle === 'PING' ) {
408
+ return this . _handleCallback ( body , responders . httpResponder ( response , this . _log ) )
407
409
}
408
410
409
411
// Work-around to issue with http-signature
410
412
// See also: https://github.com/joyent/node-http-signature/issues/87
411
- if ( request . originalUrl ) {
412
- request . url = request . originalUrl
413
+ if ( originalUrl ) {
414
+ const queryPos = originalUrl . indexOf ( '?' )
415
+ request . url = queryPos < 0 ? originalUrl : originalUrl . slice ( 0 , queryPos )
413
416
}
414
417
415
418
const isAuthorized = await this . _authorizer . isAuthorized ( request )
416
419
if ( isAuthorized ) {
417
- return this . _handleCallback ( request . body , responders . httpResponder ( response , this . _log ) )
420
+ return this . _handleCallback ( body , responders . httpResponder ( response , this . _log ) )
418
421
}
419
422
420
423
this . _log . error ( 'Unauthorized' )
@@ -428,8 +431,8 @@ class SmartApp {
428
431
* @param {* } request
429
432
* @param {* } response
430
433
*/
431
- handleHttpCallbackUnverified ( request , response ) {
432
- this . _handleCallback ( request . body , responders . httpResponder ( response , this . _log ) )
434
+ async handleHttpCallbackUnverified ( request , response ) {
435
+ return this . _handleCallback ( request . body , responders . httpResponder ( response , this . _log ) )
433
436
}
434
437
435
438
/**
0 commit comments