api-guidelines
api-guidelines copied to clipboard
Opinion on trailing slash in URL?
I heard someone claiming the URL for a collection should be have trailing slash, for example GET https://example.com/v1/articles/. And that a popular stack exchange answer also advocates for it. Does this guide have any opinion on this topic?
The / at least in my opinion denotes a resource and so I'd expect something after it. I'd suspect most naive parsers for URLs probably break on a slash - most likely it would force the developer to trim any array of items from the split before accessing it. Also doesn't force the user to have to potentially add a slash via code to support your API where others don't.