fix($resource): prevent URL template from collapsing into an empty string

Closes #5455