improve current URL detection (in JS)

fixes https://github.com/killbill/killbill/issues/245