Skip to content

Commit

Permalink
style: clean up multi-line comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Fdawgs committed Nov 14, 2022
1 parent f53ad3a commit 4227801
Show file tree
Hide file tree
Showing 24 changed files with 45 additions and 33 deletions.
6 changes: 4 additions & 2 deletions src/config/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,10 @@ async function getConfig() {
},
/* istanbul ignore next: pino functions not explicitly tested */
res(res) {
// Required for the statusCode to be logged
// https://github.com/pinojs/pino-std-serializers/blob/901dae44c2b71497cdb0f76f6b5af62588107e3e/lib/res.js#L37
/**
* Required for the statusCode to be logged:
* https://github.com/pinojs/pino-std-serializers/blob/901dae44c2b71497cdb0f76f6b5af62588107e3e/lib/res.js#L37
*/
res.headersSent = true;
return pino.stdSerializers.res(res);
},
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/docx-to-html/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ async function plugin(server) {
* Mammoth does not wrap the results inside <html> and <body> tags itself.
* `fixUtf8` function replaces most common incorrectly converted
* Windows-1252 to UTF-8 results with HTML equivalents.
* Refer to https://i18nqa.com/debug/utf8-debug.html for more info.
* Refer to https://i18nqa.com/debug/utf8-debug.html for more info
*/
req.conversionResults.body = fixUtf8(`<!DOCTYPE html>
<head>
Expand Down
14 changes: 9 additions & 5 deletions src/plugins/pdf-to-html/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,10 @@ async function plugin(server, options) {
req.conversionResults = { body: undefined };
});

// "onSend" hook used instead of "onResponse" ensures
// cancelled request temp data is also removed
/**
* "onSend" hook used instead of "onResponse" ensures
* cancelled request temp data is also removed.
*/
server.addHook("onSend", async (req, res, payload) => {
if (req?.conversionResults?.docLocation) {
// Remove files from temp directory after response sent
Expand Down Expand Up @@ -137,8 +139,10 @@ async function plugin(server, options) {
}
}

// Remove excess title and meta elements left behind by Poppler
// Poppler appends `-html` to the file name, thus the template literal here
/**
* Remove excess title and meta elements left behind by Poppler;
* Poppler appends `-html` to the file name, thus the template literal here
*/
const dom = new JSDOM(
await fs.readFile(`${tempFile}-html.html`, {
encoding: config.pdfToHtmlOptions.outputEncoding,
Expand All @@ -160,7 +164,7 @@ async function plugin(server, options) {
/**
* `fixUtf8` function replaces most common incorrectly converted
* Windows-1252 to UTF-8 results with HTML equivalents.
* Refer to https://i18nqa.com/debug/utf8-debug.html for more info.
* Refer to https://i18nqa.com/debug/utf8-debug.html for more info
*/
req.conversionResults.body = fixUtf8(dom.serialize());

Expand Down
6 changes: 4 additions & 2 deletions src/plugins/pdf-to-txt/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,10 @@ async function plugin(server, options) {
req.conversionResults = { body: undefined };
});

// "onSend" hook used instead of "onResponse" ensures
// cancelled request temp data is also removed
/**
* "onSend" hook used instead of "onResponse" ensures
* cancelled request temp data is also removed
*/
server.addHook("onSend", async (req, res, payload) => {
if (req?.conversionResults?.docLocation) {
// Remove files from temp directory after response sent
Expand Down
8 changes: 5 additions & 3 deletions src/plugins/rtf-to-html/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,10 @@ async function plugin(server, options) {
req.conversionResults = { body: undefined };
});

// "onSend" hook used instead of "onResponse" ensures
// cancelled request temp data is also removed
/**
* "onSend" hook used instead of "onResponse" ensures
* cancelled request temp data is also removed
*/
server.addHook("onSend", async (req, res, payload) => {
if (req?.conversionResults?.docLocation) {
// Remove files from temp directory after response sent
Expand Down Expand Up @@ -92,7 +94,7 @@ async function plugin(server, options) {
/**
* `fixUtf8` function replaces most common incorrectly converted
* Windows-1252 to UTF-8 results with HTML equivalents.
* Refer to https://i18nqa.com/debug/utf8-debug.html for more info.
* Refer to https://i18nqa.com/debug/utf8-debug.html for more info
*/
req.conversionResults.body = await fixUtf8(dom.serialize());
} catch (err) {
Expand Down
6 changes: 4 additions & 2 deletions src/plugins/rtf-to-txt/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,10 @@ async function plugin(server, options) {
req.conversionResults = { body: undefined };
});

// "onSend" hook used instead of "onResponse" ensures
// cancelled request temp data is also removed
/**
* "onSend" hook used instead of "onResponse" ensures
* cancelled request temp data is also removed
*/
server.addHook("onSend", async (req, res, payload) => {
if (req?.conversionResults?.docLocation) {
// Remove files from temp directory after response sent
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/tidy-css/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ async function plugin(server) {

/**
* Minifies output whilst also removing HTML comment tags
* wrapping CSS and redundant semi-colons generated by Poppler.
* wrapping CSS and redundant semi-colons generated by Poppler
*/
styleObj = styleObj.toString();
combinedStyle.innerHTML = cssCleaner.minify(styleObj).styles;
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/tidy-html/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ async function plugin(server) {
* This can be a confusing experience if the file name is not representative of the image's contents.
* See https://dequeuniversity.com/rules/axe/4.4/image-alt?application=axeAPI
*
* As such, alt attributes in <img> tags are set to an empty string rather than removed here.
* As such, alt attributes in <img> tags are set to an empty string rather than removed here
*/
if (options?.removeAlt === true) {
const images = dom.window.document.querySelectorAll("img");
Expand Down
2 changes: 1 addition & 1 deletion src/routes/admin/healthcheck/schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const tags = ["System Administration"];
* Fastify uses AJV for JSON Schema Validation,
* see https://fastify.io/docs/latest/Reference/Validation-and-Serialization/
*
* Input validation protects against XSS, HPP, and most injection attacks.
* Input validation protects against XSS, HPP, and most injection attacks
*/
const healthcheckGetSchema = {
tags,
Expand Down
2 changes: 1 addition & 1 deletion src/routes/docs/openapi/schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const S = require("fluent-json-schema");
* Fastify uses AJV for JSON Schema Validation,
* see https://fastify.io/docs/latest/Reference/Validation-and-Serialization/
*
* Input validation protects against XSS, HPP, and most injection attacks.
* Input validation protects against XSS, HPP, and most injection attacks
*/
const docsOpenapiGetSchema = {
hide: true,
Expand Down
2 changes: 1 addition & 1 deletion src/routes/docs/schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const S = require("fluent-json-schema");
* Fastify uses AJV for JSON Schema Validation,
* see https://fastify.io/docs/latest/Reference/Validation-and-Serialization/
*
* Input validation protects against XSS, HPP, and most injection attacks.
* Input validation protects against XSS, HPP, and most injection attacks
*/
const docsGetSchema = {
hide: true,
Expand Down
2 changes: 1 addition & 1 deletion src/routes/docx/html/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ async function route(server, options) {
async (req, payload) => {
/**
* The Content-Type header can be spoofed so is not trusted implicitly,
* this checks for DOCX specific magic numbers.
* this checks for DOCX specific magic numbers
*/
const results = await fromBuffer(payload);
if (
Expand Down
2 changes: 1 addition & 1 deletion src/routes/docx/html/schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const tags = ["DOCX"];
* Fastify uses AJV for JSON Schema Validation,
* see https://fastify.io/docs/latest/Reference/Validation-and-Serialization/
*
* Input validation protects against XSS, HPP, and most injection attacks.
* Input validation protects against XSS, HPP, and most injection attacks
*/
const docxToHtmlPostSchema = {
tags,
Expand Down
2 changes: 1 addition & 1 deletion src/routes/docx/txt/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ async function route(server, options) {
async (req, payload) => {
/**
* The Content-Type header can be spoofed so is not trusted implicitly,
* this checks for DOCX specific magic numbers.
* this checks for DOCX specific magic numbers
*/
const results = await fromBuffer(payload);
if (
Expand Down
2 changes: 1 addition & 1 deletion src/routes/pdf/html/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ async function route(server, options) {
async (req, payload) => {
/**
* The Content-Type header can be spoofed so is not trusted implicitly,
* this checks for PDF specific magic numbers.
* this checks for PDF specific magic numbers
*/
const results = await fromBuffer(payload);
if (
Expand Down
2 changes: 1 addition & 1 deletion src/routes/pdf/html/schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const tags = ["PDF"];
* Fastify uses AJV for JSON Schema Validation,
* see https://fastify.io/docs/latest/Reference/Validation-and-Serialization/
*
* Input validation protects against XSS, HPP, and most injection attacks.
* Input validation protects against XSS, HPP, and most injection attacks
*/
const pdfToHtmlPostSchema = {
tags,
Expand Down
2 changes: 1 addition & 1 deletion src/routes/pdf/txt/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ async function route(server, options) {
async (req, payload) => {
/**
* The Content-Type header can be spoofed so is not trusted implicitly,
* this checks for PDF specific magic numbers.
* this checks for PDF specific magic numbers
*/
const results = await fromBuffer(payload);
if (
Expand Down
2 changes: 1 addition & 1 deletion src/routes/pdf/txt/schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const tags = ["PDF"];
* Fastify uses AJV for JSON Schema Validation,
* see https://fastify.io/docs/latest/Reference/Validation-and-Serialization/
*
* Input validation protects against XSS, HPP, and most injection attacks.
* Input validation protects against XSS, HPP, and most injection attacks
*/
const pdfToTxtPostSchema = {
tags,
Expand Down
2 changes: 1 addition & 1 deletion src/routes/rtf/html/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ async function route(server, options) {
async (req, payload) => {
/**
* The Content-Type header can be spoofed so is not trusted implicitly,
* this checks for RTF specific magic numbers.
* this checks for RTF specific magic numbers
*/
const results = await fromBuffer(payload);
if (
Expand Down
2 changes: 1 addition & 1 deletion src/routes/rtf/html/schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const tags = ["RTF"];
* Fastify uses AJV for JSON Schema Validation,
* see https://fastify.io/docs/latest/Reference/Validation-and-Serialization/
*
* Input validation protects against XSS, HPP, and most injection attacks.
* Input validation protects against XSS, HPP, and most injection attacks
*/
const rtfToHtmlPostSchema = {
tags,
Expand Down
2 changes: 1 addition & 1 deletion src/routes/rtf/txt/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ async function route(server, options) {
async (req, payload) => {
/**
* The Content-Type header can be spoofed so is not trusted implicitly,
* this checks for RTF specific magic numbers.
* this checks for RTF specific magic numbers
*/
const results = await fromBuffer(payload);
if (
Expand Down
2 changes: 1 addition & 1 deletion src/routes/rtf/txt/schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const tags = ["RTF"];
* Fastify uses AJV for JSON Schema Validation,
* see https://fastify.io/docs/latest/Reference/Validation-and-Serialization/
*
* Input validation protects against XSS, HPP, and most injection attacks.
* Input validation protects against XSS, HPP, and most injection attacks
*/
const rtfToTxtPostSchema = {
tags,
Expand Down
2 changes: 1 addition & 1 deletion src/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ async function plugin(server, config) {
* `x-xss-protection` and `content-security-policy` is set by default by Helmet.
* These are only useful for HTML/XML content; the only CSP directive that
* is of use to other content is "frame-ancestors 'none'" to stop responses
* from being wrapped in iframes and used for clickjacking attacks.
* from being wrapped in iframes and used for clickjacking attacks
*/
.addHook("onSend", async (req, res, payload) => {
if (
Expand Down
2 changes: 1 addition & 1 deletion src/server.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -881,7 +881,7 @@ describe("Server Deployment", () => {
await page.goto("http://localhost:8204/docs");
expect(await page.title()).toBe("Docsmith | Documentation");
/**
* Checks redoc has not rendered an error component
* Checks redoc has not rendered an error component:
* https://github.com/Redocly/redoc/blob/main/src/components/ErrorBoundary.tsx
*/
const heading = page.locator("h1 >> nth=0");
Expand Down

0 comments on commit 4227801

Please sign in to comment.