smarter url replacement that respects the request's protocol
Merge remote-tracking branch 'origin/master'