Removing any trailing slash from a URL - Node.js String

Node.js examples for String:URL String

Description

Removing any trailing slash from a URL

Demo Code

function removeTrailingSlash(url) {
  return (url[url.length - 1] == "/") ? url.substr(0, url.length - 1) : url;
}

Related Tutorials