rustdoc: Check for href when prepending rootPath

Fixes the JS error in #18354 at least. I don't know if there's a more underlying issue that needs addressing.