enables inline PDFs for sources

This commit is contained in:
Lachlan Kermode
2020-02-19 18:19:26 +13:00
parent 87f640be00
commit 4ea856fa18
4 changed files with 26 additions and 5 deletions

View File

@@ -153,17 +153,24 @@ export function selectTypeFromPath (path) {
return { type, path }
}
export function selectTypeFromPathWithPoster (path, poster) {
export function typeForPath (path) {
let type
path = path.trim()
switch (true) {
case /\.(png|jpg)$/.test(path):
case /\.((png)|(jpg))$/.test(path):
type = 'Image'; break
case /\.(mp4)$/.test(path):
type = 'Video'; break
case /\.(md)$/.test(path):
type = 'Text'; break
case /\.(pdf)$/.test(path):
type = 'Document'; break
default:
type = 'Unknown'; break
}
return { type, path, poster }
return type
}
export function selectTypeFromPathWithPoster (path, poster) {
return { type: typeForPath(path), path, poster }
}