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:
parent
62ddc31a9e
commit
d4a8e7a65f
94 changed files with 1029 additions and 673 deletions
32
server/helpers/uuid.ts
Normal file
32
server/helpers/uuid.ts
Normal 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
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue