Skip to content

Commit

Permalink
[cli-common] parseClusterUrl considers undefined to return default lo…
Browse files Browse the repository at this point in the history
…calhost
  • Loading branch information
ochaloup committed Jan 11, 2024
1 parent 7e31ead commit 81021d2
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions packages/lib/cli-common/src/parsers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,8 @@ export async function parseWalletOrPubkey(
}
}

export function parseClusterUrl(url: string): string {
export function parseClusterUrl(url: string | undefined): string {
const localhost = 'http://127.0.0.1:8899'
let clusterUrl =
url === 'd'
? 'devnet'
Expand All @@ -127,15 +128,15 @@ export function parseClusterUrl(url: string): string {
: url === 'm' || url === 'mainnet'
? 'mainnet-beta'
: url === 'l' || url === 'localnet' || url === 'localhost'
? 'http://127.0.0.1:8899'
? localhost
: url

try {
clusterUrl = clusterApiUrl(clusterUrl as Cluster)
clusterUrl = clusterApiUrl(clusterUrl as Cluster | undefined)
} catch (e) {
// ignore
}
return clusterUrl
return clusterUrl || localhost
}

export function parseCommitment(commitment: string): Commitment {
Expand Down

0 comments on commit 81021d2

Please sign in to comment.