From 03c7f662d20952e04f6d25af2115fa39a530c483 Mon Sep 17 00:00:00 2001 From: Thibaud Colas Date: Wed, 17 Jan 2018 10:56:33 +0200 Subject: [PATCH] Make Draftail document rendering logic sturdier --- client/src/components/Draftail/decorators/Document.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/client/src/components/Draftail/decorators/Document.js b/client/src/components/Draftail/decorators/Document.js index 2c7357a7d2..f04f6ab261 100644 --- a/client/src/components/Draftail/decorators/Document.js +++ b/client/src/components/Draftail/decorators/Document.js @@ -7,16 +7,21 @@ import TooltipEntity from '../decorators/TooltipEntity'; const documentIcon = ; +const getFilename = (path) => { + const splitPath = path.split('/'); + + return splitPath[splitPath.length - 1]; +}; + const Document = props => { const { entityKey, contentState } = props; const { url } = contentState.getEntity(entityKey).getData(); - const filename = url.split('/')[3]; return ( );