Merge pull request +9895 from c9/fix-profile-base-url

Fix profile base url
pull/223/head
Matthijs van Henten 2015-10-20 14:19:32 +02:00
commit 6960ab7b0e
1 zmienionych plików z 21 dodań i 3 usunięć

24
node_modules/c9/urls.js wygenerowano vendored
Wyświetl plik

@ -25,9 +25,27 @@ function main(options, imports, register) {
/**
* Get a desired base URL, given some context.
*
* @param req The current request object or URL
* @param {String} [sourceUrlPattern] The source URL pattern, e.g. https://ide.$DOMAIN
* @param {String} targetBaseUrlPattern The target URL pattern, e.g. https://$DOMAIN
* Example for a request coming into the IDE service:
*
* ```
* getBaseUrl(req, "https://ide.$DOMAIN", "https://preview.$DOMAIN");
* ```
*
* The above example will determine the domain name from the request,
* by stripping off the "https://ide." part. So, for a domain like
* "https://ide.c9.io" we'll get "c9.io". For a domain like
* "https://ide.dogfooding-lennartcl.c9.io" we'll get dogfooding-lennartcl.c9.io.
* If there is no match, a warning is shown. The target pattern
* is used to construct the resulting URL, e.g. https://preview.c9.io.
*
* @param req
* The current request object or URL
* @param {String} [sourceUrlPattern]
* The URL pattern of the current service, e.g. https://ide.$DOMAIN if
* we are getting an incoming request for the IDE service
* @param {String} targetBaseUrlPattern
* The URL pattern of the target service. E.g., if we want to
* construct the base URL of the API service, this might be https://api.$DOMAIN.
*/
plugin.getBaseUrl = function(req, sourceBaseUrlPattern, targetBaseUrlPattern) {
var sourceHost = req.headers && req.headers.host