diff --git a/aio/src/app/documents/document.service.spec.ts b/aio/src/app/documents/document.service.spec.ts index 0449c23405..9381aa019b 100644 --- a/aio/src/app/documents/document.service.spec.ts +++ b/aio/src/app/documents/document.service.spec.ts @@ -121,12 +121,15 @@ describe('DocumentService', () => { expect(latestDocument).toEqual(doc1); subscription.unsubscribe(); }); + }); - + describe('computeMap', () => { it('should map the "empty" location to the correct document request', () => { let latestDocument: DocumentContents; const { service, backend } = getServices(); service.currentDocument.subscribe(doc => latestDocument = doc); + + expect(backend.connectionsArray[0].request.url).toEqual(CONTENT_URL_PREFIX + 'index.json'); }); }); }); diff --git a/aio/src/app/documents/document.service.ts b/aio/src/app/documents/document.service.ts index a4d12dd9c4..e0774dd21a 100644 --- a/aio/src/app/documents/document.service.ts +++ b/aio/src/app/documents/document.service.ts @@ -43,8 +43,8 @@ export class DocumentService { .get(path) .map(res => res.json()) .catch((error: Response) => { - if (error.status === 404 && url !== FILE_NOT_FOUND_DOC) { - this.logger.error(`Document file not found at '${url}'`); + if (error.status === 404 && path !== FILE_NOT_FOUND_DOC) { + this.logger.error(`Document file not found at '${path}'`); // using `getDocument` means that we can fetch the 404 doc contents from the server and cache it return this.getDocument(FILE_NOT_FOUND_DOC); } else { @@ -57,6 +57,7 @@ export class DocumentService { private computePath(url) { url = url.startsWith('/') ? url : '/' + url; + url = url.endsWith('/') ? url + 'index' : url; return 'content/docs' + url + '.json'; } }