modify token url logic

mimic .NET changes #68

better handling for situations where the request to be proxied is
pointing at a Portal Url that doesn't include '/rest/'