From the logic it looks good to me. three small comments:
a) the backslashes are not needed within the condition (since it is between curly brackes)
b) since all what's needed is the leading match, string match is better and faster than regexp
c) is the ns_urldecode $return_url
really needed? the preceding util_complete_url_p
does a regexp on the return_url without decoding.