Introduce get the base algorithm to make it easier for Location to reuse URLUtils.

Fixes https://www.w3.org/Bugs/Public/show_bug.cgi?id=20929