diff --git a/apps/datahub-e2e/src/e2e/dataset.cy.ts b/apps/datahub-e2e/src/e2e/dataset.cy.ts index ac17d89..f25c515 100644 --- a/apps/datahub-e2e/src/e2e/dataset.cy.ts +++ b/apps/datahub-e2e/src/e2e/dataset.cy.ts @@ -263,10 +263,14 @@ describe('datasets', () => { .first() .should('have.attr', 'download', '') }) - it('should contain download attribute with filename data.json for json files', () => { + it('should contain download attribute with filename for json files', () => { cy.get('[data-cy="download-button"]') .eq(2) - .should('have.attr', 'download', 'data.json') + .should( + 'have.attr', + 'download', + 'insee:rectangles_200m_menage_erbm.json' + ) }) it('should open link in new tab as fallback (if download attribute is ignored, for not same-origin)', () => { cy.get('[data-cy="download-button"]') diff --git a/apps/datahub/src/app/dataset/dataset-downloads/download-item/download-item.component.ts b/apps/datahub/src/app/dataset/dataset-downloads/download-item/download-item.component.ts index ea77063..5721643 100644 --- a/apps/datahub/src/app/dataset/dataset-downloads/download-item/download-item.component.ts +++ b/apps/datahub/src/app/dataset/dataset-downloads/download-item/download-item.component.ts @@ -15,12 +15,13 @@ export class MelDownloadItemComponent extends DownloadItemComponent { // note that the download attribute calling this getter only takes effect on same-origin resources get downloadFileName() { - let fileName = '' + let completeFileName = '' + const fileName = this.link.name ?? 'data' if (this.format === 'geojson') { - fileName = 'data.geojson' + completeFileName = `${fileName}.geojson` } else if (this.format === 'json') { - fileName = 'data.json' + completeFileName = `${fileName}.json` } - return fileName + return completeFileName } }