Maybe too basic of a question but wanted to see if there is more to it than I am thinking.
When configuring URLs (baseUrls, like
https://my.app or relative URLs like
/path/to/resource) either as a static variable, in configuration files or environment variables etc., what should my 'slash strategy' be?
One of my coworkers mentioned that I should always configure base URLs with a trailing slash (
https://my.app/) and paths with a leading and trailing slash (
/path/to/resource/) because in most cases when you concatenate these, you may end up with double slashes (
http://my.app//path/to/resource/) but most tools can handle that. If the claim that most tools can handle it is true, this could be an attractive approach since all you need to know is to always use slashes everywhere.
The other solutions could either be to follow and be consistent with either one of these approaches:
- No trailing slashes but always use leading ones (
- No leading slashes, but always use trailing ones (
Is there a best strategy? Would the strategies be dependent on the tools being used (like libraries that can handle one but not the other?)