Provide a better error if ROOT_URL is not an URL

Fixes #1404.
This commit is contained in:
David Glasser
2014-04-22 15:52:52 -07:00
parent fe13c30bfd
commit a8869d07ec
2 changed files with 22 additions and 2 deletions

View File

@@ -1,6 +1,15 @@
if (process.env.ROOT_URL &&
typeof __meteor_runtime_config__ === "object") {
__meteor_runtime_config__.ROOT_URL = process.env.ROOT_URL;
var pathPrefix = Npm.require('url').parse(__meteor_runtime_config__.ROOT_URL).pathname;
__meteor_runtime_config__.ROOT_URL_PATH_PREFIX = pathPrefix === "/" ? "" : pathPrefix;
if (__meteor_runtime_config__.ROOT_URL) {
var parsedUrl = Npm.require('url').parse(__meteor_runtime_config__.ROOT_URL);
// Sometimes users try to pass, eg, ROOT_URL=mydomain.com.
if (!parsedUrl.host) {
throw Error("$ROOT_URL, if specified, must be an URL");
}
var pathPrefix = parsedUrl.pathname;
__meteor_runtime_config__.ROOT_URL_PATH_PREFIX = pathPrefix === "/" ? "" : pathPrefix;
} else {
__meteor_runtime_config__.ROOT_URL_PATH_PREFIX = "";
}
}

View File

@@ -337,6 +337,17 @@ Fiber(function () {
process.exit(1);
}
// This is a bit of a hack, but: if we don't check this in the tool, then the
// first time we do a unipackage.load, it will fail due to the check in the
// meteor package, and that'll look a lot uglier.
if (process.env.ROOT_URL) {
var parsedUrl = require('url').parse(process.env.ROOT_URL);
if (!parsedUrl.host) {
process.stderr.write('$ROOT_URL, if specified, must be an URL.\n');
process.exit(1);
}
}
// Parse the arguments.
//
// We must first identify which options are boolean and which take