Vonage / vonage-node-sdk

Vonage API client for Node.js. API support for SMS, Voice, Text-to-Speech, Numbers, Verify (2FA) and more.
Apache License 2.0
375 stars 178 forks source link

Make sure that URL Overrides strip ending `/` from URLs #739

Closed dragonmantank closed 1 year ago

dragonmantank commented 1 year ago

Expected Behavior

According to https://developer.vonage.com/messages/code-snippets/whatsapp/send-text, you can set the base URL for the API to https://api.nexmo.com/, with a trailing slash. This breaks the routing as the SDK expects the URL without a / at the end.

Current Behavior

We should allow the user to enter a URL with or without a slash, and strip it if it exists.

Possible Solution

We should be able to add some code to server-client in the constructor to clean this up, as well as in the main server-sdk package. It would need to be done in both places as server-client handles it for all the sub-packages, but the main package doesn't extend from there so it also needs to handle it.

Steps to Reproduce (for bugs)

  1. Create a new Vonage object and set the base URL to https://api.nexmo.com/
  2. Try and hit a resource using that URL like applications

Context

Submitted by a user in our internal devrel chat

Your Environment

manchuck commented 1 year ago

I have checked and vetch will not append extra /