1
0
Fork 0
mirror of https://github.com/Chocobozzz/PeerTube.git synced 2025-10-06 03:50:26 +02:00

Support short uuid for GET video/playlist

This commit is contained in:
Chocobozzz 2021-06-28 17:30:59 +02:00 committed by Chocobozzz
parent 62ddc31a9e
commit d4a8e7a65f
94 changed files with 1029 additions and 673 deletions

32
server/helpers/uuid.ts Normal file
View file

@ -0,0 +1,32 @@
import * as short from 'short-uuid'
const translator = short()
function buildUUID () {
return short.uuid()
}
function uuidToShort (uuid: string) {
if (!uuid) return uuid
return translator.fromUUID(uuid)
}
function shortToUUID (shortUUID: string) {
if (!shortUUID) return shortUUID
return translator.toUUID(shortUUID)
}
function isShortUUID (value: string) {
if (!value) return false
return value.length === translator.maxLength
}
export {
buildUUID,
uuidToShort,
shortToUUID,
isShortUUID
}