Snippet #5 - Lowercase URI's and trailing slashes

Here's a couple rapid-fire snippets to help you manipulate HTTP request URI's. The first converts all characters in a URI to lowercase before submitting the request to the backend server. Node.js (and javascript) provide some very helpful string manipulation methods -

toLowerCase()
is one.

In the second snippet, we're using a simple regex check and string concatenation to ensure that any URI has a trailing forward slash before being passed to the backend server.

Updated Jun 05, 2023
Version 2.0
No CommentsBe the first to comment