Remove conditional assignment from Document URL

The conditional assignment was making results from `url` quite outdated, causing #2557.

This PR provides a fix for the issue as well as a test covering document permalinks.
Does the `permalink` method not take from `data`?