diff --git a/src/fetch.js b/src/fetch.js index 4fe2bb98..de8b635d 100644 --- a/src/fetch.js +++ b/src/fetch.js @@ -28,7 +28,7 @@ module.exports.save = function (krokiDiagram, doc, target, vfs, krokiClient) { const dirPath = getDirPath(doc) const diagramUrl = krokiDiagram.getDiagramUri(krokiClient.getServerUrl()) const format = krokiDiagram.format - const diagramName = target ? `${target}.${format}` : `diag-${rusha.createHash().update(diagramUrl).digest('hex')}.${format}` + const diagramName = `diag-${rusha.createHash().update(diagramUrl).digest('hex')}.${format}` const filePath = path.format({ dir: dirPath, base: diagramName }) let encoding let mediaType diff --git a/test/test.spec.js b/test/test.spec.js index e5fe5b9c..6d75f232 100644 --- a/test/test.spec.js +++ b/test/test.spec.js @@ -133,7 +133,7 @@ Hello -> World const registry = asciidoctor.Extensions.create() asciidoctorKroki.register(registry) const html = asciidoctor.convert(input, { extension_registry: registry, attributes: { 'kroki-fetch-diagram': true } }) - expect(html).to.contain('hello-world') + expect(html).to.contain('hello-world') }) it('should download and save an image to a local folder and generated name', () => { const input = ` @@ -204,26 +204,6 @@ AsciiDoc -> HTML5: convert http.get.restore() } }) - it('should not download twice the same image with target name', () => { - const input = ` -:imagesdir: .asciidoctor/kroki - -[plantuml,asciidoc-html5,svg,role=sequence] -.... -AsciiDoc -> HTML5: convert -.... -` - sinon.spy(http, 'get') - try { - const registry = asciidoctor.Extensions.create() - asciidoctorKroki.register(registry) - const html = asciidoctor.convert(input, { extension_registry: registry, attributes: { 'kroki-fetch-diagram': true } }) - expect(html).to.contain('asciidoc-html5') - expect(http.get.calledOnce).to.be.true() - } finally { - http.get.restore() - } - }) it('should create a literal block when format is txt', () => { const input = ` [plantuml,format=txt]