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

Make getEndpointURL (fileinfo) case insensitive #73

Open
paulo-ocean opened this issue Jul 4, 2024 · 0 comments · May be fixed by #74
Open

Make getEndpointURL (fileinfo) case insensitive #73

paulo-ocean opened this issue Jul 4, 2024 · 0 comments · May be fixed by #74
Assignees

Comments

@paulo-ocean
Copy link

we have these 2 calls:
const endpoint = await getEndpointURL(providerUrl, 'fileinfo')
const endpoint = await getEndpointURL(providerURL, 'download')

getEndpointURL() should be case insensitive. "fileinfo" is a special case, since its the only provider route that does not follow camelCase, the express routes are case insensitive by default, so it treats fileinfo equal to fileInfo. The issue is that the service name check (from provider root endpoint) is case sensitive at the moment, so it can easily break...
Solution:
Make this function checks case insensitive

async function getEndpointURL(providerURL, serviceName) {
  const response = await fetch(providerURL, {
    method: 'GET',
    headers: {
      'Content-type': 'application/json'
    }
  })
  const providerData = await response.json()
  for (const i in providerData.serviceEndpoints) {
    if (i === serviceName) {
      return providerData.serviceEndpoints[i]
    }
  }
  return null
}
@paulo-ocean paulo-ocean self-assigned this Jul 4, 2024
@paulo-ocean paulo-ocean linked a pull request Jul 4, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant