Tips for concatenating URLs in JavaScript

1 · Patrick Smith · Oct. 1, 2020, 1:32 a.m.
You might have a base URL from configuration, that you then concatenate with paths to produce a full URL. Say an API URL you fetch from. But should you provide the base URL with or without a trailing slash? e.g. Should you have https://api.example.org/ or https://api.example.org? If you simply combine the strings together, you can […]...