diff --git a/lib/url.js b/lib/url.js index b8538e6..eaf3c06 100644 --- a/lib/url.js +++ b/lib/url.js @@ -159,6 +159,7 @@ Url.parse = function (url) { var match = url.match(re); + var pathPrefix = __meteor_runtime_config__.ROOT_URL_PATH_PREFIX; var protocol = match[1] ? match[1].toLowerCase() : undefined; var hostWithSlashes = match[3]; var slashes = !!hostWithSlashes; @@ -181,8 +182,8 @@ Url.parse = function (url) { var hostWithPortParts = (host && host.split(':')) || []; var hostname = hostWithPortParts[0]; var port = hostWithPortParts[1]; - var origin = (protocol && host) ? protocol + '//' + host : undefined; - var pathname = match[5]; + var origin = (protocol && host) ? protocol + '//' + host + pathPrefix : undefined; + var pathname = match[5].replace(pathPrefix, ''); var hash = match[8]; var originalUrl = url; @@ -205,16 +206,13 @@ Url.parse = function (url) { var path = pathname + (search || ''); var queryObject = Url.fromQueryString(query); - var rootUrl = [ - protocol || '', - slashes ? '//' : '', - hostWithAuth || '' - ].join(''); + var rootUrl = __meteor_runtime_config__.ROOT_URL; var href = [ protocol || '', slashes ? '//' : '', hostWithAuth || '', + pathPrefix || '', pathname || '', search || '', hash || '' @@ -366,6 +364,8 @@ Url.prototype.resolve = function (params, options) { } } + path = __meteor_runtime_config__.ROOT_URL_PATH_PREFIX + path; + // Because of optional possibly empty segments we normalize path here path = path.replace(/\/+/g, '/'); // Multiple / -> one / path = path.replace(/^(.+)\/$/g, '$1'); // Removal of trailing /