Skip to content
This repository was archived by the owner on Sep 14, 2021. It is now read-only.

Commit fe9b471

Browse files
committed
allow spaces in role name
1 parent de5b16e commit fe9b471

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

bot/src/commands/admin.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,13 @@ const INVALID_NUMBER_OF_PARAMETERS = 'Invalid number of parameters'
1414
const { verifyInstall, getRoleFromName } = require('./common')
1515

1616
const parseParams = ({ text }) => {
17-
// !eg. "add-lock 0xabc1 100 role-name url-for-buying"
18-
const params = text.split(' ')
19-
if (params.length < 5) throw Error('#' + INVALID_NUMBER_OF_PARAMETERS)
20-
const [_, chainId, contractAddress, balance, roleName, purchaseUrl] = params
17+
// !eg. add-lock 0xabc1 100 "role name" url-for-buying"
18+
const initialParams = text.split(' ').slice(0, 2)
19+
const role = text.split('"')[1]
20+
if (initialParams.length < 4 || !role)
21+
throw Error('#' + INVALID_NUMBER_OF_PARAMETERS)
22+
const purchaseUrl = text.split('"')[2]
23+
const [_, chainId, contractAddress, balance] = initialParams
2124
if (!chainId.match(/^[0-9]+$/)) throw Error('#' + 'Invalid chain ID')
2225
if (!contractAddress.match(/^0x[0-9a-fA-F]{40}$/))
2326
throw Error('#' + INVALID_ETHEREUM_ADDRESS)

0 commit comments

Comments
 (0)