developerforce / Force.com-JavaScript-REST-Toolkit

ForceTK - a minimal Force.com REST API for JavaScript apps
BSD 3-Clause "New" or "Revised" License
315 stars 175 forks source link

salesforce proxy url is not correct if the browser url is formed differently by sso #95

Open sumeetbath opened 6 years ago

sumeetbath commented 6 years ago

Salesforce proxy url is looking at element[0] or element[1] of url split by dot in order to get domain. which is not always correct. I think domain should be obtained from {!$Api.Enterprise_Server_URL_410} to make sure it is always correct and it need to be always passed. I think fixing comments will help users or we should use salesforcebase url

/**
     * Set a session token and the associated metadata in the client.
     * @param sessionId a salesforce.com session ID. In a Visualforce page,
     *                   use '{!$Api.sessionId}' to obtain a session ID.
     * @param [apiVersion="v29.0"] Force.com API version
     * @param [instanceUrl] Omit this if running on Visualforce; otherwise 
     *                   use the value from the OAuth token.
     */
    forcetk.Client.prototype.setSessionToken = function(sessionId, apiVersion, instanceUrl) {