aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/helpers/utils.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/helpers/utils.ts')
-rw-r--r--server/helpers/utils.ts17
1 files changed, 16 insertions, 1 deletions
diff --git a/server/helpers/utils.ts b/server/helpers/utils.ts
index 6228fec04..39afb4e7b 100644
--- a/server/helpers/utils.ts
+++ b/server/helpers/utils.ts
@@ -77,6 +77,20 @@ async function getVersion () {
77 return require('../../../package.json').version 77 return require('../../../package.json').version
78} 78}
79 79
80/**
81 * From a filename like "ede4cba5-742b-46fa-a388-9a6eb3a3aeb3.mp4", returns
82 * only the "ede4cba5-742b-46fa-a388-9a6eb3a3aeb3" part. If the filename does
83 * not contain a UUID, returns null.
84 */
85function getUUIDFromFilename (filename: string) {
86 const regex = /[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/
87 const result = filename.match(regex)
88
89 if (!result || Array.isArray(result) === false) return null
90
91 return result[0]
92}
93
80// --------------------------------------------------------------------------- 94// ---------------------------------------------------------------------------
81 95
82export { 96export {
@@ -86,5 +100,6 @@ export {
86 getSecureTorrentName, 100 getSecureTorrentName,
87 getServerActor, 101 getServerActor,
88 getVersion, 102 getVersion,
89 generateVideoTmpPath 103 generateVideoTmpPath,
104 getUUIDFromFilename
90} 105}