mirror of https://github.com/BTCPrivate/copay.git
sanitized value in uri
This commit is contained in:
parent
0be9ee9231
commit
df48069c63
|
@ -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)) {
|
||||
|
|
Loading…
Reference in New Issue