diff --git a/js/controllers/send.js b/js/controllers/send.js index 960f439d0..59f1ee383 100644 --- a/js/controllers/send.js +++ b/js/controllers/send.js @@ -420,8 +420,22 @@ angular.module('copayApp.controllers').controller('SendController', }; $scope.setFromUri = function(uri) { + function sanitizeUri(uri) { + // Fixes when a region uses comma to separate decimals + var regex = /[\?\&]amount=(\d+([\,\.]\d+)?)/i; + var match = regex.exec(uri); + if (!match || match.length === 0) { + return uri; + } + var value = match[0].replace(',', '.'); + var newUri = uri.replace(regex, value); + return newUri; + }; + var form = $scope.sendForm; + uri = sanitizeUri(uri); + var parsed = new bitcore.BIP21(uri); if (!parsed.isValid() || !parsed.address.isValid()) { $scope.error = 'Invalid bitcoin URL'; @@ -444,9 +458,6 @@ angular.module('copayApp.controllers').controller('SendController', $scope.error = $scope.success = null; if (!value) return ''; - // Fixes when a region uses comma to separate decimals - value = value.replace(',', '.'); - if (value.indexOf('bitcoin:') === 0) { return $scope.setFromUri(value); } else if (/^https?:\/\//.test(value)) {