Attempted to handle URLs with anchors correctly. Added tests, but five of them still fail.

Here's a PR, but at least the tests need some more work to pass again.