From 26feea9275bbba0d7b3fceedd10298e5deb81f08 Mon Sep 17 00:00:00 2001 From: David Greenspan Date: Mon, 29 Sep 2014 12:57:09 -0700 Subject: [PATCH] =?UTF-8?q?Don=E2=80=99t=20be=20all=20weird=20if=20ROOT=5F?= =?UTF-8?q?URL=20ends=20with=20`/`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- packages/meteor/url_server.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/meteor/url_server.js b/packages/meteor/url_server.js index 9eee42f0c3..9abcb03a13 100644 --- a/packages/meteor/url_server.js +++ b/packages/meteor/url_server.js @@ -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 = ""; }