+ Start a Discussion
Jim F.ax281Jim F.ax281 

RegEx for validating SF URL for community users

Hi all,

We've got a .NET application that we use to make API calls to different Salesforce instances, and use a user's API Server URL and Session ID to pull data.  As part of the security process, we use a RegEx to validate that the server URL being passed is correct:

https://[^/?]+\\.(sales|visual\\.)force\\.com/services/(S|s)(O|o)(A|a)(P|p)/(u|c)/.*

To date, this RegEx has worked well.  However, we've found that SF Community users have an API Server URL that fails this RegEx.  It looks something like this in a Sandbox - I haven't yet seen what it looks like on a live org:
https://test--whatever--community.cs7.force.com/partners/services/Soap/u/22.0

Is there an updated version of the RegEx that works for both Standard users and Community users?

Thanks, Jim