Regex should be as specific as possible, but also general enough to work on different pages. To achieve this balance, use customer-specific prefixes.
The Regex for each environment must be different. Prefixes also come in handy here.
Begin and end every string of regex with .*
Instead of using digits, use .*. Replace any numbers in a URL with .*
Make sure to put a \ before every period.
No need to escape hyphens.
To include a URL with two or more different prefixes use (first|second|third|etc.) where the prefixes occur.
For regex to exclude a word, refer to the below example, where you want to create an extension with one editor account on Salesforce Classic and one on Salesforce Console.
To include more than one regex in a package, place an | in between each regex with no spaces.
Make sure to never leave two consecutive || in a package, as this will cause a allow list and match to all URLs and introduce errors on certain sites.
Regex is case sensitive. Be sure to match the correct case of the URL within the regex.
There may be a scenario where you need to "tighten" the regex to exclude a specific frame. For instance, you may only want WalkMe to inject in a specific iFrame, but that iFrame's domain is included in many other iFrames as a reference.
Example of iFrame domain you want WalkMe to appear in:
Example of iFrame domain that we are trying to prevent WalkMe from injecting into:
To specify that regex that must come at the beginning of the URL, we use:
Using, this WalkMe will only inject into the https://visual.force.com iFrame if its the first part of the URL.
There are a number of extensions we are often asked to configure that are standard.
It is extremely important to build Salesforce extensions carefully and to test them in a number of test scenarios due to the variance in the platform across pages and the presence of many analytics iFrames that take up 0px.
Website | Example URLs | Suggested Regex |
Salesforce Classic | https://panasonic--fullcopy.cs24.my.salesforce.com/ https://panasonic--fullcopy--field-trip.cs24.visual.force.com/ |
.*customername.*.cs.*.my.salesforce.com.*|.*cs.*.salesforce.com/(?!console).*|.*cs.*.visual.force.com.* |
Salesforce Lightning | https://cs24.lightning.force.com/ | .*cs.*.lightning.force.com.* |
Salesforce Console | https://cs6.salesforce.com/console?tsid=02u50000000e56v | .*cs.*.salesforce.com/console.* |
Website | Example URLs | Suggested Regex |
Salesforce Classic | https://panasonic.my.salesforce.com/home/home.jsp https://panasonic--c.na34.visual.force.com/ |
.*customername.my.salesforce.com.*|.*na.*.salesforce.com/(?!console).*|.*na.*.visual.force.com.* |
Salesforce Lightning | https://na34.lightning.force.com/ | .*na.*.lightning.force.com.* |
Salesforce Console | https://na2.salesforce.com/console?tsid=02u50000000e56v | .*na.*.salesforce.com/console.* |
Example URL | Suggested Regex |
impl.workday.com/tripadvisor/d/home.htmld | .*impl.workday.com/customername.* |
Example URL | Suggested Regex |
https://www.myworkday.com/sunbeltrentals/login.flex | .*myworkday.com/customername.* |
Example URL | Suggested Regex |
https://hcm4preview.sapsf.com/ | .*hcm.*preview.sapsf.com.* |
Example URL | Suggested Regex |
https://performancemanager5.successfactors.com/ | .*performancemanager.*.successfactors.com.* |
In configuring an extension, you will often need multiple packages for different platforms, for example, one for normal Salesforce (SFDC) and another for Service Cloud. In such cases, your browser extension will utilize regex to differentiate between platforms and inject different snippets into these different platforms as appropriate. In the SFDC Service Cloud hypothetical, we could use regex to differentiate between these platforms as follows:
Normal SFDC URL:
Normal Service Cloud URL:
Regex statement for the extension to capture any Service Cloud URL:
This hones in on the appearance of the term "console" immediately after the salesforce.com domain.
Because a clear difference between the Service Cloud URL and the SFDC URL is the appearance of the word "console" immediately after "salesforce.com", we can use this to our advantage.
Using the regex symbols "?!", we can single out all instances of "salesforce.com" that are not followed by the word "console", and, given our two base URLs, we know these will be SFDC URLs.
SFDC regex:
Here, "?!console" means any URL possessing the items in this regex, where "console" does NOT appear in this position in the expression.
This will not match https://cs2.salesforce.com/console?tsid=02u50000000e56v, but it will match https://cs2.salesforce.com/home/home.jsp?tsid=02u0000000000hV.se