if extension has a slash return last value after it

Signed-off-by: Jakub Sokołowski <jakub@status.im>
This commit is contained in:
Jakub Sokołowski 2019-02-06 09:50:41 +01:00
parent ef1176ec7d
commit 9e2dd15c10
No known key found for this signature in database
GPG Key ID: 4EF064D0E6D63020
1 changed files with 7 additions and 1 deletions

View File

@ -19,7 +19,13 @@ const dateHelper = (data) => new Handlebars.SafeString(
)
/* extracts file extension from url */
const fileExt = (data) => new Handlebars.SafeString(data.split('.').pop())
const fileExt = (data) => {
let ext = data.split('.').pop()
if (ext.includes('/')) {
ext = ext.split('/').pop()
}
return new Handlebars.SafeString(ext)
}
/* remove seconds from duration to make columns equal width */
const shortenDuration = (data) => (data.replace(/ [0-9]+ sec$/, ''))