Skip to content

Commit 672fe33

Browse files
committed
chore: update polling example
1 parent 813dece commit 672fe33

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

examples/express-polling.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,13 @@ const onComplete: express.RequestHandler = (req, res) => {
2121
const moving = (processes[file.name] ??= {} as Moving);
2222
if (!moving.status) {
2323
moving.status = 'moving';
24-
const source = storage.getFilePath(file.name);
25-
const destination = path.resolve(moveTo, file.originalName);
2624
void (async () => {
2725
try {
26+
const source = storage.getFilePath(file.name);
27+
const destination = path.resolve(moveTo, file.originalName);
28+
if (!destination.startsWith(path.resolve(moveTo))) {
29+
throw new Error(`Invalid destination path: ${destination}`);
30+
}
2831
await copyFile(source, destination);
2932
await storage.delete(file);
3033
moving.status = 'done';

0 commit comments

Comments
 (0)