Skip to content

Commit 8a15cff

Browse files
code improvement
1 parent 0c08035 commit 8a15cff

1 file changed

Lines changed: 2 additions & 6 deletions

File tree

pdf-service.js

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ app.post('/from-html', async (req, res) => {
6060

6161
app.get('/from-url', async (req, res) => {
6262
calls.fromUrl++;
63-
const url = withHttp(req.query.url);
63+
let url = req.query.url;
6464
console.log('/from-url');
6565

6666
if (!url) {
@@ -71,7 +71,7 @@ app.get('/from-url', async (req, res) => {
7171

7272
let pdfFilePath;
7373
try {
74-
pdfFilePath = await generatePdf(url, req.query.media);
74+
pdfFilePath = await generatePdf(withHttp(url), req.query.media);
7575

7676
deliverPdfFile(res, pdfFilePath);
7777
} catch (err) {
@@ -83,10 +83,6 @@ app.get('/from-url', async (req, res) => {
8383
});
8484

8585
function withHttp (url) {
86-
if (!url) {
87-
return;
88-
}
89-
9086
return !/^https?:\/\//i.test(url)
9187
? `http://${url}`
9288
: url;

0 commit comments

Comments
 (0)