fix(aio): map the empty url to the correct doc path
This commit is contained in:
parent
dd50922747
commit
4abd6f333c
|
@ -121,12 +121,15 @@ describe('DocumentService', () => {
|
||||||
expect(latestDocument).toEqual(doc1);
|
expect(latestDocument).toEqual(doc1);
|
||||||
subscription.unsubscribe();
|
subscription.unsubscribe();
|
||||||
});
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('computeMap', () => {
|
||||||
it('should map the "empty" location to the correct document request', () => {
|
it('should map the "empty" location to the correct document request', () => {
|
||||||
let latestDocument: DocumentContents;
|
let latestDocument: DocumentContents;
|
||||||
const { service, backend } = getServices();
|
const { service, backend } = getServices();
|
||||||
service.currentDocument.subscribe(doc => latestDocument = doc);
|
service.currentDocument.subscribe(doc => latestDocument = doc);
|
||||||
|
|
||||||
|
expect(backend.connectionsArray[0].request.url).toEqual(CONTENT_URL_PREFIX + 'index.json');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -43,8 +43,8 @@ export class DocumentService {
|
||||||
.get(path)
|
.get(path)
|
||||||
.map(res => res.json())
|
.map(res => res.json())
|
||||||
.catch((error: Response) => {
|
.catch((error: Response) => {
|
||||||
if (error.status === 404 && url !== FILE_NOT_FOUND_DOC) {
|
if (error.status === 404 && path !== FILE_NOT_FOUND_DOC) {
|
||||||
this.logger.error(`Document file not found at '${url}'`);
|
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
|
// using `getDocument` means that we can fetch the 404 doc contents from the server and cache it
|
||||||
return this.getDocument(FILE_NOT_FOUND_DOC);
|
return this.getDocument(FILE_NOT_FOUND_DOC);
|
||||||
} else {
|
} else {
|
||||||
|
@ -57,6 +57,7 @@ export class DocumentService {
|
||||||
|
|
||||||
private computePath(url) {
|
private computePath(url) {
|
||||||
url = url.startsWith('/') ? url : '/' + url;
|
url = url.startsWith('/') ? url : '/' + url;
|
||||||
|
url = url.endsWith('/') ? url + 'index' : url;
|
||||||
return 'content/docs' + url + '.json';
|
return 'content/docs' + url + '.json';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue