0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2025-12-24 20:42:43 +00:00

Fixes from Linter

This commit is contained in:
G.Ambatte
2021-01-21 20:32:23 +13:00
parent 5c7a9c92d1
commit 06223d576d

View File

@@ -99,8 +99,8 @@ const shareFunction = function(req, res, type) {
const setSourceHeaders = function (res, title, type) {
res.status(200);
if (type == 'download') {
let fileName = sanitizeFilename(title).replaceAll(' ', '-');
if(type == 'download') {
const fileName = sanitizeFilename(title).replaceAll(' ', '-');
res.set({
'Cache-Control' : 'no-cache',
@@ -108,18 +108,18 @@ const setSourceHeaders = function (res, title, type) {
'Content-Disposition' : `attachment; filename="HomeBrewery-${fileName}.txt"`
});
}
}
};
const getSourceText = function (brewText, type) {
if(type == 'source') {
return `<code><pre style="white-space: pre-wrap;">${brewText.replaceAll('&', '&amp;').replaceAll('<','&lt;').replaceAll('>', '&gt;')}</pre></code>`;
return `<code><pre style="white-space: pre-wrap;">${brewText.replaceAll('&', '&amp;').replaceAll('<', '&lt;').replaceAll('>', '&gt;')}</pre></code>`;
} else if(type == 'download') {
return brewText;
} else {
console.log('Unhandled source share type');
return;
}
}
};
//Source page
app.get('/source/:id', (req, res)=>{