mirror of https://codeberg.org/pzp/pzp-invite.git
fix corner cases when creating invites
This commit is contained in:
parent
731395ea97
commit
745eea3de0
13
lib/index.js
13
lib/index.js
|
@ -114,7 +114,6 @@ function parseJoinCommand(pieces, uri) {
|
|||
function parseFollowCommand(pieces, uri) {
|
||||
const [label, id] = pieces
|
||||
if (!id) {
|
||||
// prettier-ignore
|
||||
throw new Error(`Invalid URI "${uri}" for invite.parse, missing follow id`)
|
||||
}
|
||||
pieces.shift()
|
||||
|
@ -213,14 +212,12 @@ function parsePromiseAccountAddCommand(pieces, uri) {
|
|||
function parse(uri) {
|
||||
const url = new URL(uri)
|
||||
if (url.protocol !== 'ppppp:') {
|
||||
throw new Error(
|
||||
`Invalid protocol in URI "${uri}" for invite.parse, expected "ppppp:"`
|
||||
)
|
||||
// prettier-ignore
|
||||
throw new Error(`Invalid protocol in URI "${uri}" for invite.parse, expected "ppppp:"`)
|
||||
}
|
||||
if (url.host !== 'invite') {
|
||||
throw new Error(
|
||||
`Invalid host in URI "${uri}" for invite.parse, expected "invite"`
|
||||
)
|
||||
// prettier-ignore
|
||||
throw new Error(`Invalid host in URI "${uri}" for invite.parse, expected "invite"`)
|
||||
}
|
||||
const pieces = url.pathname.startsWith('/')
|
||||
? url.pathname.substring(1).split('/')
|
||||
|
@ -291,6 +288,8 @@ async function makeJoinCommands(peer, amountHubs, hardcodedHub) {
|
|||
: await p(peer.hubClient.getHubs)(amountHubs)
|
||||
// prettier-ignore
|
||||
if (err1) return [new Error('Failed to get hubs while creating invite', { cause: err1 })]
|
||||
// prettier-ignore
|
||||
if (hubMultiaddrs.length === 0) return [new Error('No hubs available while creating invite')]
|
||||
|
||||
// For each hub, connect and create token
|
||||
const hubErrors = []
|
||||
|
|
Loading…
Reference in New Issue