From 04e7f9e6a9f617c43048d85751de3289bad00917 Mon Sep 17 00:00:00 2001
From: Adhidarma Hadiwinoto <me@adhisimon.org>
Date: Thu, 19 Dec 2019 17:21:14 +0700
Subject: [PATCH] BUY: trim product name and destination

---
 lib/command-handler/buy.js | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/command-handler/buy.js b/lib/command-handler/buy.js
index 65d0355..9ae6042 100644
--- a/lib/command-handler/buy.js
+++ b/lib/command-handler/buy.js
@@ -38,8 +38,8 @@ function execute(tokens, params, cb) {
         report_ip: params.report_ip,
         report_port: params.report_port,
         terminal_name: params.from,
-        product_name: tokens[1].toUpperCase(),
-        destination: tokens[2].replace(/^\+62/, '0'),
+        product_name: (tokens[1] || '').trim().toUpperCase(),
+        destination: (tokens[2] || '').trim().replace(/^\+62/, '0'),
         password: tokens[3],
         request_id: `${generateRequestId(tokens[1], tokens[2])}${Number(tokens[4]) ? '_req' + Number(tokens[4]) : ''}`,
         postpaid: 0
-- 
1.9.0