Scanning or pasting ordinary URL gives the option to open it in a browser.
This commit is contained in:
parent
98f317dea7
commit
918451f3da
5 changed files with 71 additions and 18 deletions
|
|
@ -3866,3 +3866,11 @@ msgstr ""
|
||||||
#: src/js/controllers/tab-scan.js:121
|
#: src/js/controllers/tab-scan.js:121
|
||||||
msgid "Testnet is not supported."
|
msgid "Testnet is not supported."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
#: www/views/includes/incomingDataMenu.html:81
|
||||||
|
msgid "URL"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: www/views/includes/incomingDataMenu.html:90
|
||||||
|
msgid "Open in web browser"
|
||||||
|
msgstr ""
|
||||||
|
|
@ -93,6 +93,7 @@
|
||||||
returns:
|
returns:
|
||||||
{
|
{
|
||||||
amount: '',
|
amount: '',
|
||||||
|
bareUrl: '',
|
||||||
coin: '',
|
coin: '',
|
||||||
copayInvitation: '',
|
copayInvitation: '',
|
||||||
isValid: false,
|
isValid: false,
|
||||||
|
|
@ -163,6 +164,9 @@
|
||||||
addressAndParams = colonSplit[1];
|
addressAndParams = colonSplit[1];
|
||||||
console.log('No prefix.');
|
console.log('No prefix.');
|
||||||
|
|
||||||
|
} else if (/^https?$/.test(colonSplit[1])) {
|
||||||
|
addressAndParams = trimmed;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// Something with a colon in the middle that we don't recognise
|
// Something with a colon in the middle that we don't recognise
|
||||||
return parsed;
|
return parsed;
|
||||||
|
|
@ -253,6 +257,7 @@
|
||||||
var privateKeyForUncompressedPublicKeyTestnetRe = /^9[1-9A-HJ-NP-Za-km-z]{50}$/;
|
var privateKeyForUncompressedPublicKeyTestnetRe = /^9[1-9A-HJ-NP-Za-km-z]{50}$/;
|
||||||
var privateKeyForCompressedPublicKeyRe = /^[KL][1-9A-HJ-NP-Za-km-z]{51}$/;
|
var privateKeyForCompressedPublicKeyRe = /^[KL][1-9A-HJ-NP-Za-km-z]{51}$/;
|
||||||
var privateKeyForCompressedPublicKeyTestnetRe = /^[c][1-9A-HJ-NP-Za-km-z]{51}$/;
|
var privateKeyForCompressedPublicKeyTestnetRe = /^[c][1-9A-HJ-NP-Za-km-z]{51}$/;
|
||||||
|
var urlRe = /^https?:\/\/.+/;
|
||||||
|
|
||||||
var bitpayAddrMainnet = bitpayAddrOnMainnet(address);
|
var bitpayAddrMainnet = bitpayAddrOnMainnet(address);
|
||||||
var cashAddrTestnet = cashAddrOnTestnet(addressLowerCase);
|
var cashAddrTestnet = cashAddrOnTestnet(addressLowerCase);
|
||||||
|
|
@ -322,6 +327,10 @@
|
||||||
} else if (privateKeyEncryptedRe.test(address)) {
|
} else if (privateKeyEncryptedRe.test(address)) {
|
||||||
parsed.privateKey = { encrypted: address };
|
parsed.privateKey = { encrypted: address };
|
||||||
parsed.isValid = true;
|
parsed.isValid = true;
|
||||||
|
|
||||||
|
} else if (urlRe.test(address)) {
|
||||||
|
parsed.bareUrl = trimmed;
|
||||||
|
parsed.isValid = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -343,11 +343,20 @@ fdescribe('bitcoinUriService', function() {
|
||||||
expect(parsed.isValid).toBe(false);
|
expect(parsed.isValid).toBe(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('URL only', function() {
|
it('URL only, http', function() {
|
||||||
|
|
||||||
var parsed = bitcoinUriService.parse('https://www.google.com');
|
var parsed = bitcoinUriService.parse('http://paperwallet.bitcoin.com');
|
||||||
|
|
||||||
expect(parsed.isValid).toBe(false);
|
expect(parsed.isValid).toBe(true);
|
||||||
|
expect(parsed.bareUrl).toBe('http://paperwallet.bitcoin.com');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('URL only, https with query', function() {
|
||||||
|
|
||||||
|
var parsed = bitcoinUriService.parse('https://purse.io/?one=two&three=four');
|
||||||
|
|
||||||
|
expect(parsed.isValid).toBe(true);
|
||||||
|
expect(parsed.bareUrl).toBe('https://purse.io/?one=two&three=four');
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
angular.module('copayApp.services').factory('incomingData', function(bitcoinUriService, $log, $state, $timeout, $ionicHistory, bitcore, bitcoreCash, $rootScope, payproService, scannerService, sendFlowService, appConfigService, popupService, gettextCatalog, bitcoinCashJsService) {
|
angular.module('copayApp.services').factory('incomingData', function(externalLinkService, bitcoinUriService, $log, $state, $timeout, $ionicHistory, bitcore, bitcoreCash, $rootScope, payproService, scannerService, sendFlowService, appConfigService, popupService, gettextCatalog, bitcoinCashJsService) {
|
||||||
|
|
||||||
var root = {};
|
var root = {};
|
||||||
|
|
||||||
|
|
@ -251,20 +251,23 @@ angular.module('copayApp.services').factory('incomingData', function(bitcoinUriS
|
||||||
);
|
);
|
||||||
return true;
|
return true;
|
||||||
// Plain URL
|
// Plain URL
|
||||||
} else if (/^https?:\/\//.test(data)) {
|
} else if (allParsed.bareUrl) {
|
||||||
payproService.getPayProDetails(data, coin, function(err, details) {
|
|
||||||
if (err) {
|
if ($state.includes('tabs.scan')) {
|
||||||
if ($state.includes('tabs.scan')) {
|
root.showMenu({
|
||||||
root.showMenu({
|
data: allParsed.bareUrl,
|
||||||
data: data,
|
type: 'url'
|
||||||
type: 'url'
|
});
|
||||||
});
|
} else {
|
||||||
}
|
externalLinkService.open(
|
||||||
return;
|
allParsed.bareUrl,
|
||||||
}
|
true,
|
||||||
handlePayPro(details);
|
gettextCatalog.getString('Open in web browser'),
|
||||||
return true;
|
allParsed.bareUrl
|
||||||
});
|
);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
|
||||||
// Plain Address
|
// Plain Address
|
||||||
} else if (bitcore.Address.isValid(data, 'livenet') || bitcore.Address.isValid(data, 'testnet')) {
|
} else if (bitcore.Address.isValid(data, 'livenet') || bitcore.Address.isValid(data, 'testnet')) {
|
||||||
if ($state.includes('tabs.scan')) {
|
if ($state.includes('tabs.scan')) {
|
||||||
|
|
|
||||||
|
|
@ -76,4 +76,28 @@
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div ng-if="type === 'url'">
|
||||||
|
<div class="incoming-data-menu__item head">
|
||||||
|
<div class="incoming-data-menu__header" translate>URL</div>
|
||||||
|
<div class="incoming-data-menu__url">
|
||||||
|
<div class="incoming-data-menu__url__text" style="border: 0;">
|
||||||
|
{{data}}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<a class="incoming-data-menu__item item item-icon-right" ng-click="goToUrl(data)">
|
||||||
|
<img src="img/icon-link-external.svg">
|
||||||
|
<div class="incoming-data-menu__item__text" translate>Open in web browser</div>
|
||||||
|
<i class="icon bp-arrow-right"></i>
|
||||||
|
</a>
|
||||||
|
<a class="incoming-data-menu__item item item-icon-right" copy-to-clipboard="data">
|
||||||
|
<img src="img/icon-paperclip.svg">
|
||||||
|
<div class="incoming-data-menu__item__text" translate>Copy to clipboard</div>
|
||||||
|
<i class="icon bp-arrow-right"></i>
|
||||||
|
</a>
|
||||||
|
<a class="incoming-data-menu__cancel item" ng-click="hide()" translate>
|
||||||
|
Cancel
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
</action-sheet>
|
</action-sheet>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue