Skip to content

Commit

Permalink
refactor: remove optional chaining for first level properties (#1338)
Browse files Browse the repository at this point in the history
  • Loading branch information
Fdawgs authored Mar 20, 2023
1 parent 435312c commit 1b14dc7
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 12 deletions.
12 changes: 6 additions & 6 deletions src/config/config.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ describe("Configuration", () => {
const CORS_ALLOWED_HEADERS =
"Accept, Authorization, Content-Type, Origin, X-Requested-With";
const CORS_ALLOW_CREDENTIALS =
envVariables?.CORS_ALLOW_CREDENTIALS || "";
envVariables.CORS_ALLOW_CREDENTIALS || "";
const CORS_EXPOSED_HEADERS = "Location";
const CORS_MAX_AGE = 10;
const LOG_LEVEL = "trace";
Expand All @@ -437,7 +437,7 @@ describe("Configuration", () => {
expect(config.cors).toEqual({
origin: expected.origin,
allowedHeaders: CORS_ALLOWED_HEADERS,
credentials: expected?.credentials || false,
credentials: expected.credentials || false,
exposedHeaders: CORS_EXPOSED_HEADERS,
hideOptionsRoute: true,
maxAge: CORS_MAX_AGE,
Expand Down Expand Up @@ -465,10 +465,10 @@ describe("Configuration", () => {
])("Should throw error if $testName", async ({ envVariables }) => {
const HOST = "0.0.0.0";
const PORT = 443;
const HTTPS_SSL_KEY_PATH = envVariables?.HTTPS_SSL_KEY_PATH || "";
const HTTPS_SSL_CERT_PATH = envVariables?.HTTPS_SSL_CERT_PATH || "";
const HTTPS_PFX_FILE_PATH = envVariables?.HTTPS_PFX_FILE_PATH || "";
const HTTPS_PFX_PASSPHRASE = envVariables?.HTTPS_PFX_PASSPHRASE || "";
const HTTPS_SSL_KEY_PATH = envVariables.HTTPS_SSL_KEY_PATH || "";
const HTTPS_SSL_CERT_PATH = envVariables.HTTPS_SSL_CERT_PATH || "";
const HTTPS_PFX_FILE_PATH = envVariables.HTTPS_PFX_FILE_PATH || "";
const HTTPS_PFX_PASSPHRASE = envVariables.HTTPS_PFX_PASSPHRASE || "";
const LOG_LEVEL = "trace";

Object.assign(process.env, {
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/pdf-to-html/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ async function plugin(server, options) {
* cancelled request temp data is also removed.
*/
server.addHook("onSend", async (req, _res, payload) => {
if (req?.conversionResults?.docLocation) {
if (req.conversionResults?.docLocation) {
// Remove files from temp directory after response sent
const files = await glob(
`${path.joinSafe(
Expand Down
4 changes: 2 additions & 2 deletions src/plugins/pdf-to-txt/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ async function plugin(server, options) {
* cancelled request temp data is also removed
*/
server.addHook("onSend", async (req, _res, payload) => {
if (req?.conversionResults?.docLocation) {
if (req.conversionResults?.docLocation) {
// Remove files from temp directory after response sent
const files = await glob(
`${path.joinSafe(
Expand Down Expand Up @@ -125,7 +125,7 @@ async function plugin(server, options) {
* image-to-txt plugin adds the "tesseract" decorator to server instance,
* if this is missing then OCR is not supported
*/
if (query?.ocr === true && server.tesseract) {
if (query.ocr === true && server.tesseract) {
// Prune params that pdfToCairo cannot accept
Object.keys(query).forEach((value) => {
if (!pdfToCairoAcceptedParams.includes(value)) {
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/rtf-to-html/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ async function plugin(server, options) {
* cancelled request temp data is also removed
*/
server.addHook("onSend", async (req, _res, payload) => {
if (req?.conversionResults?.docLocation) {
if (req.conversionResults?.docLocation) {
// Remove files from temp directory after response sent
const files = await glob(
`${path.joinSafe(
Expand Down
4 changes: 2 additions & 2 deletions src/plugins/tidy-html/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ async function plugin(server) {
const dom = new JSDOM(html);

// Set document language if valid IANA language tag and subtag
const language = options?.language || "en";
const language = options.language || "en";
if (!check(language)) {
throw server.httpErrors.badRequest(
"querystring.language not a valid IANA language tag"
Expand All @@ -45,7 +45,7 @@ async function plugin(server) {
*
* As such, alt attributes in <img> tags are set to an empty string rather than removed here
*/
if (options?.removeAlt === true) {
if (options.removeAlt === true) {
dom.window.document.querySelectorAll("img").forEach((element) => {
element.setAttribute("alt", "");
});
Expand Down

0 comments on commit 1b14dc7

Please sign in to comment.