Skip to content

Commit

Permalink
Accept "Simple" URIs
Browse files Browse the repository at this point in the history
  • Loading branch information
adityapk00 committed Apr 8, 2021
1 parent fa98ae0 commit fbbe14d
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions app/uris.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export const parseZcashURI = (uri: string): ZcashURITarget[] | string => {
}

const parsedUri = new Url(uri, true);
if (!parsedUri || parsedUri.protocol !== 'zcash:' || !parsedUri.query) {
if (!parsedUri || parsedUri.protocol !== 'zcash:') {
return 'Bad URI';
}
//console.log(parsedUri);
Expand Down Expand Up @@ -127,13 +127,24 @@ export const parseZcashURI = (uri: string): ZcashURITarget[] | string => {
}

// Make sure everyone has at least an amount and address
for (const [key, value] of targets) {
if (typeof value.amount === 'undefined') {
return `URI ${key} didn't have an amount`;
if (targets.size > 1) {
for (const [key, value] of targets) {
if (typeof value.amount === 'undefined') {
return `URI ${key} didn't have an amount`;
}

if (typeof value.address === 'undefined') {
return `URI ${key} didn't have an address`;
}
}
} else {
// If there is only 1 entry, make sure it has at least an address
if (!targets.get(0)) {
return 'URI Should have at least 1 entry';
}

if (typeof value.address === 'undefined') {
return `URI ${key} didn't have an address`;
if (typeof targets.get(0)?.address === 'undefined') {
return `URI ${0} didn't have an address`;
}
}

Expand Down

0 comments on commit fbbe14d

Please sign in to comment.