diff --git a/src/components/forms/AccountForm.js b/src/components/forms/AccountForm.js index 0842d4c..f9b6298 100644 --- a/src/components/forms/AccountForm.js +++ b/src/components/forms/AccountForm.js @@ -265,12 +265,12 @@ const AccountForm = props => { } const axiosData = { - name, - sip_realm: sipRealm || null, + name: name.trim(), + sip_realm: sipRealm.trim() || null, registration_hook: { - url: regWebhook, + url: regWebhook.trim(), method: method, - username: user || null, + username: user.trim() || null, password: password || null, }, }; diff --git a/src/components/forms/ApplicationForm.js b/src/components/forms/ApplicationForm.js index 5cf31f0..16dc4f5 100644 --- a/src/components/forms/ApplicationForm.js +++ b/src/components/forms/ApplicationForm.js @@ -321,17 +321,17 @@ const ApplicationForm = props => { const data = { account_sid: accountSid, - name, + name: name.trim(), call_hook: { - url: callWebhook, + url: callWebhook.trim(), method: callWebhookMethod, - username: callWebhookUser || null, + username: callWebhookUser.trim() || null, password: callWebhookPass || null, }, call_status_hook: { - url: statusWebhook, + url: statusWebhook.trim(), method: statusWebhookMethod, - username: statusWebhookUser || null, + username: statusWebhookUser.trim() || null, password: statusWebhookPass || null, }, speech_synthesis_vendor: speechSynthesisVendor, diff --git a/src/components/forms/PhoneNumberForm.js b/src/components/forms/PhoneNumberForm.js index 3d3d067..2ef3d8e 100644 --- a/src/components/forms/PhoneNumberForm.js +++ b/src/components/forms/PhoneNumberForm.js @@ -264,8 +264,10 @@ const PhoneNumberForm = props => { application_sid: application || null, }; + const cleanedUpNumber = phoneNumber.trim().replace(/[\s-()+]/g,''); + if (props.type === 'add') { - data.number = phoneNumber; + data.number = cleanedUpNumber; data.voip_carrier_sid = sipTrunk; } diff --git a/src/components/forms/SipTrunkForm.js b/src/components/forms/SipTrunkForm.js index 8501e10..b3c7acb 100644 --- a/src/components/forms/SipTrunkForm.js +++ b/src/components/forms/SipTrunkForm.js @@ -247,11 +247,11 @@ const SipTrunkForm = props => { //----------------------------------------------------------------------------- // IP validation //----------------------------------------------------------------------------- - const type = regIp.test(gateway.ip) + const type = regIp.test(gateway.ip.trim()) ? 'ip' - : regFqdn.test(gateway.ip) + : regFqdn.test(gateway.ip.trim()) ? 'fqdn' - : regFqdnTopLevel.test(gateway.ip) + : regFqdnTopLevel.test(gateway.ip.trim()) ? 'fqdn-top-level' : 'invalid'; @@ -287,9 +287,9 @@ const SipTrunkForm = props => { //----------------------------------------------------------------------------- if ( gateway.port && ( - !(regPort.test(gateway.port)) - || (parseInt(gateway.port) < 0) - || (parseInt(gateway.port) > 65535) + !(regPort.test(gateway.port.toString().trim())) + || (parseInt(gateway.port.toString().trim()) < 0) + || (parseInt(gateway.port.toString().trim()) > 65535) ) ) { errorMessages.push('Please provide a valid port number between 0 and 65535'); @@ -390,8 +390,8 @@ const SipTrunkForm = props => { Authorization: `Bearer ${localStorage.getItem('token')}`, }, data: { - name, - description, + name: name.trim(), + description: description.trim(), }, }); const voip_carrier_sid = voipCarrier.data.sid; @@ -429,8 +429,8 @@ const SipTrunkForm = props => { : `/SipGateways/${s.sip_gateway_sid}`; const data = { - ipv4: s.ip, - port: s.port, + ipv4: s.ip.trim(), + port: s.port.toString().trim(), inbound: s.inbound, outbound: s.outbound, };