Skip to content
This repository was archived by the owner on Jan 10, 2024. It is now read-only.

Commit 74b2cdd

Browse files
author
Pat Patterson
committed
Merge pull request #28 from jpearson-sfdc/master
Add support for custom domains from My Domains
2 parents 6f9efca + e30e637 commit 74b2cdd

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

forcetk.js

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -126,11 +126,20 @@ if (forcetk.Client === undefined) {
126126
this.apiVersion = (typeof apiVersion === 'undefined' || apiVersion === null)
127127
? 'v24.0': apiVersion;
128128
if (typeof instanceUrl === 'undefined' || instanceUrl == null) {
129-
// location.hostname can be of the form 'abc.na1.visual.force.com' or
130-
// 'na1.salesforce.com'. Split on '.', and take the [1] or [0] element
131-
// as appropriate
129+
// location.hostname can be of the form 'abc.na1.visual.force.com',
130+
// 'na1.salesforce.com' or 'abc.my.salesforce.com' (custom domains).
131+
// Split on '.', and take the [1] or [0] element as appropriate
132132
var elements = location.hostname.split(".");
133-
var instance = (elements.length == 3) ? elements[0] : elements[1];
133+
134+
var instance = null;
135+
if(elements.length == 4 && elements[1] === 'my') {
136+
instance = elements[0] + '.' + elements[1];
137+
} else if(elements.length == 3){
138+
instance = elements[0];
139+
} else {
140+
instance = elements[1];
141+
}
142+
134143
this.instanceUrl = "https://" + instance + ".salesforce.com";
135144
} else {
136145
this.instanceUrl = instanceUrl;

0 commit comments

Comments
 (0)