api-guidelines icon indicating copy to clipboard operation
api-guidelines copied to clipboard

Opinion on trailing slash in URL?

Open chiawendt opened this issue 6 years ago • 1 comments

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?

chiawendt avatar Oct 13 '19 21:10 chiawendt

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.

tanepiper avatar Dec 04 '19 18:12 tanepiper