Skip to content

Commit

Permalink
decode the URL before trying to use it
Browse files Browse the repository at this point in the history
  • Loading branch information
PipeItToDevNull committed Nov 2, 2024
1 parent fbe4efe commit 656b755
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
4 changes: 3 additions & 1 deletion api/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import rateLimit from 'express-rate-limit';
import { fileURLToPath } from 'url';
import winston from 'winston';
import cors from 'cors';
import { unquote } from 'querystring';

// Define __filename and __dirname using import.meta.url
const __filename = fileURLToPath(import.meta.url);
Expand Down Expand Up @@ -113,7 +114,8 @@ const handleAnalyzeDmp = async (req, res) => {
analyzeFile(filePath, res);
} else if (req.body.url) {
// If a URL is provided
const url = req.body.url;
const encodedUrl = req.body.url;
const url = unquote(encodedUrl); // Decode the URL
const fileName = path.basename(url);
const filePath = path.join(uploadsDir, fileName);

Expand Down
11 changes: 11 additions & 0 deletions api/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"marked": "^5.0.2",
"multer": "^1.4.5-lts.1",
"path": "^0.12.7",
"querystring": "^0.2.1",
"winston": "^3.16.0"
}
}

0 comments on commit 656b755

Please sign in to comment.