docs(aio): adjust zips/plunker paths

This commit is contained in:
Jesus Rodriguez
2017-04-20 13:33:31 +02:00
committed by Pete Bacon Darwin
parent d855e90524
commit 4598af23c0
6 changed files with 18 additions and 7 deletions

View File

@ -200,6 +200,15 @@ describe('LiveExampleComponent', () => {
expect(anchor.getAttribute('title')).toBe(liveExampleContent, 'title');
});
}));
it('should not duplicate the exampleDir on a zip when there is a / on the name', async(() => {
setHostTemplate('<live-example name="testing/ts"></live-example>');
testComponent(() => {
const hrefs = getHrefs();
expect(hrefs[0]).toContain('/testing/ts/eplnkr.html');
expect(hrefs[1]).toContain('/testing/ts/testing.zip');
});
}));
});
describe('when embedded', () => {

View File

@ -80,6 +80,7 @@ export class LiveExampleComponent implements OnInit {
showEmbedded = false;
title: string;
zip: string;
zipName: string;
constructor(
private elementRef: ElementRef,
@ -92,8 +93,9 @@ export class LiveExampleComponent implements OnInit {
exampleDir = location.path(false).match(/[^\/?\#]+(?=\/?(?:$|\#|\?))/)[0];
}
this.exampleDir = exampleDir.trim();
this.zipName = exampleDir.indexOf('/') === -1 ? this.exampleDir : exampleDir.split('/')[0];
this.plnkrName = attrs.plnkr ? attrs.plnkr.trim() + '.' : '';
this.zip = `${zipBase}${exampleDir}/${this.plnkrName}${exampleDir}.zip`;
this.zip = `${zipBase}${exampleDir}/${this.plnkrName}${this.zipName}.zip`;
const noDownload = this.getAttrValue(['noDownload', 'nodownload']); // noDownload aliases
this.enableDownload = !boolFromAtty(noDownload);