Fix accounting for trailing slash when adding a hook