pull/117/merge
Lennart kats 2015-06-29 08:41:18 +00:00
rodzic d19366c653
commit 23f3e6e809
2 zmienionych plików z 11 dodań i 5 usunięć

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

@ -25,9 +25,9 @@ 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
* @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
*/
plugin.getBaseUrl = function(req, sourceBaseUrlPattern, targetBaseUrlPattern) {
var sourceHost = req.host || req;
@ -39,10 +39,10 @@ plugin.getBaseUrl = function(req, sourceBaseUrlPattern, targetBaseUrlPattern) {
if (!hostMatch) {
errorLogger.log(new Error("Could not construct URL: request host "
+ sourceHost + " should match " + sourceBaseUrlPattern));
return replaceDomain(targetBaseUrlPattern, "c9.io");
return replaceDomain(targetBaseUrlPattern || sourceBaseUrlPattern, "c9.io");
}
return replaceDomain(targetBaseUrlPattern, hostMatch[1]);
return replaceDomain(targetBaseUrlPattern || sourceBaseUrlPattern, hostMatch[1]);
};
plugin.replaceDomains = function(settings, domains) {

6
node_modules/c9/urls_test.js wygenerowano vendored
Wyświetl plik

@ -120,4 +120,10 @@ describe("urls", function() {
var baseUrl = urls.getBaseUrl(input, "https://preview.$DOMAIN", "https://ide.$DOMAIN");
assert.equal(baseUrl, "https://ide.newclient-lennartcl.c9.io");
});
it("targetBaseUrlPattern is optional", function() {
var input = "https://preview.newclient-lennartcl.c9.io";
var baseUrl = urls.getBaseUrl(input, "https://preview.$DOMAIN");
assert.equal(baseUrl, "https://preview.newclient-lennartcl.c9.io");
});
});