(fileId: unknown)
| 297 | const FILE_ID_PATTERN = /^[A-Za-z0-9_-]{1,128}$/; |
| 298 | |
| 299 | function assertSafeFileId(fileId: unknown): void { |
| 300 | if (typeof fileId !== "string" || !FILE_ID_PATTERN.test(fileId)) { |
| 301 | throw handleApiError( |
| 302 | 400, |
| 303 | `Rejected import with invalid fileId: ${JSON.stringify(fileId)}`, |
| 304 | "Invalid upload identifier.", |
| 305 | ); |
| 306 | } |
| 307 | } |
| 308 | |
| 309 | function assertWithinUserDir(userTempDir: string, targetPath: string): void { |
| 310 | const base = path.resolve(userTempDir); |
no test coverage detected