diff --git a/lib/fetch.js b/lib/fetch.js index 1e2ef96..4e7de94 100644 --- a/lib/fetch.js +++ b/lib/fetch.js @@ -23,7 +23,8 @@ module.exports = function getSchema(listingUrl, callback){ } var declarationUrl = resourceObject.path.replace('{format}', 'json'); - getApiDeclarations(listingUrl, declarationUrl, apiDeclarationHandler); + var baseUrl = resourceListing.basePath || listingUrl; + getApiDeclarations(baseUrl, declarationUrl, apiDeclarationHandler); }); }; @@ -43,8 +44,11 @@ function getApiDeclarationUrl(listingUrl, declarationUrl) { // declaration path should be relative, but may be absolute declarationUrl = url.parse(declarationUrl); if(declarationUrl.hostname) return url.format(declarationUrl); - - listingUrl.pathname += declarationUrl.path; + + if (listingUrl.pathname[listingUrl.pathname.length - 1] == '/') { + listingUrl.pathname = listingUrl.pathname.substr(0, listingUrl.pathname.length - 1); + } + listingUrl.pathname += declarationUrl.pathname; return url.format(listingUrl); } @@ -67,4 +71,4 @@ function getJson(resource, callback){ } }); }).on('error', callback); -} \ No newline at end of file +}