(
userId: string,
input:
| { videoId: string; subpath: string }
| {
// deprecated
fileKey: string;
},
)
| 1 | export function parseVideoIdOrFileKey( |
| 2 | userId: string, |
| 3 | input: |
| 4 | | { videoId: string; subpath: string } |
| 5 | | { |
| 6 | // deprecated |
| 7 | fileKey: string; |
| 8 | }, |
| 9 | ) { |
| 10 | let videoId: string; |
| 11 | let subpath: string; |
| 12 | |
| 13 | if ("fileKey" in input) { |
| 14 | const [_, _videoId, ...subpathParts] = input.fileKey.split("/"); |
| 15 | if (!_videoId) throw new Error("Invalid fileKey"); |
| 16 | videoId = _videoId; |
| 17 | subpath = subpathParts.join("/"); |
| 18 | } else { |
| 19 | videoId = input.videoId; |
| 20 | subpath = input.subpath; |
| 21 | } |
| 22 | |
| 23 | return `${userId}/${videoId}/${subpath}`; |
| 24 | } |
no outgoing calls
no test coverage detected