Correctly handle trailing slash

Fixes #27