I have just discovered (thanks to a tweet by @jeffreykemp) that in APEX 5.0 there is now a function called APEX_PAGE.GET_URL:
About time! I've been using this home-made version for years:
So if I want to create a URL that redirects back to the same page with a request I can just write:
return my_apex_utils.fp (p_request=>'MYREQUEST');
One difference is that the one I use has a parameter to decide whether or not to "prepare" the URL (add the checksum etc.) This has been needed sometimes to ensure a URL is not prepared by the function because APEX goes ahead and prepares it again resulting in an invalid URL with two checksums. If I recall correctly this can happen when the URL is used in a branch. Perhaps this doesn't happen in APEX 5.0 though?