Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove trailing slashes from endpoints #961

Merged
merged 2 commits into from
Oct 21, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions libs/src/services/ethContracts/serviceProviderFactoryClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,16 @@ class ServiceProviderFactoryClient extends GovernedContractClient {
}

async registerWithDelegate (serviceType, endpoint, amount, delegateOwnerWallet) {
if (!this.isDebug && !Utils.isFQDN(endpoint)) {
const sanitizedEndpoint = endpoint.replace(/\/$/, '')

if (!this.isDebug && !Utils.isFQDN(sanitizedEndpoint)) {
throw new Error('Not a fully qualified domain name!')
}
if (!Number.isInteger(amount) && !Utils.isBN(amount)) {
throw new Error('Invalid amount')
}

const requestUrl = urlJoin(endpoint, 'health_check')
const requestUrl = urlJoin(sanitizedEndpoint, 'health_check')
const axiosRequestObj = {
url: requestUrl,
method: 'get',
Expand Down Expand Up @@ -61,7 +63,7 @@ class ServiceProviderFactoryClient extends GovernedContractClient {
// Register and stake
const method = await this.getMethod('register',
Utils.utf8ToHex(serviceType),
endpoint,
sanitizedEndpoint,
amount,
delegateOwnerWallet)
const tx = await this.web3Manager.sendTransaction(method, 1000000)
Expand Down Expand Up @@ -278,7 +280,7 @@ class ServiceProviderFactoryClient extends GovernedContractClient {
const info = await method.call()
return {
owner: info.owner,
endpoint: info.endpoint,
endpoint: info.endpoint.replace(/\/$/, ''),
spID: parseInt(serviceId),
type: serviceType,
blockNumber: parseInt(info.blockNumber),
Expand Down