Don’t be all weird if ROOT_URL ends with /

Previously, ROOT_URLs of `http://foo.com`, `http://foo.com/`, and `http://foo.com/bar` worked fine, but `http://foo.com/bar/` did not work because of the trailing slash.  We could throw an error, but why not just trim it off.
This commit is contained in:
David Greenspan
2014-09-29 12:57:09 -07:00
parent 3693db8562
commit 26feea9275

View File

@@ -8,7 +8,11 @@ if (process.env.ROOT_URL &&
throw Error("$ROOT_URL, if specified, must be an URL");
}
var pathPrefix = parsedUrl.pathname;
__meteor_runtime_config__.ROOT_URL_PATH_PREFIX = pathPrefix === "/" ? "" : pathPrefix;
if (pathPrefix.slice(-1) === '/') {
// remove trailing slash (or turn "/" into "")
pathPrefix = pathPrefix.slice(0, -1);
}
__meteor_runtime_config__.ROOT_URL_PATH_PREFIX = pathPrefix;
} else {
__meteor_runtime_config__.ROOT_URL_PATH_PREFIX = "";
}