What's the proper way to escape special characters for a Node.js REST API?

For example if I make a GET request as follows

http://mydomain.com/username/James B. Smith

Only 'James B' gets returned to the server. I'm guessing the rest is treated as a file extension. I have tried encodeURI and encodeURIComponent but they do not properly encode '.'.