DocumentUrlDB::replace calls DocumentUrlDB::put, which silently
discards invalid URLs. In case of an invalid URL, the old URL/name
is removed from the DB, but the new one is never inserted.
Move the core of the function to a private helper (implementing both
delete and rename/move), and make replace a trivial wrapper.