Use startURL instead of retURL

When logging into orgs that use OpenID Connect, the retURL parameter is not used to redirect the user to the correct page, they are instead pushed to their normal desktop home page. I think the correct parameter to use is startURL as documented here
https://help.salesforce.com/HTViewHelpDoc?id=sso_provider_addl_params_start.htm&language=en_US
I also think the string needs URL encoding.
Sadly I don't have the ability to compile and test this, so I'm keeping my fingers crossed!