Skip to content

Commit

Permalink
Merge pull request #361 from Fdawgs/build/deps
Browse files Browse the repository at this point in the history
  • Loading branch information
Fdawgs authored Feb 22, 2024
2 parents 9542260 + 35d25c9 commit dd64eaf
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 18 deletions.
20 changes: 10 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,30 +74,30 @@
"testTimeout": 10000
},
"devDependencies": {
"@commitlint/cli": "^18.5.0",
"@commitlint/config-conventional": "^18.5.0",
"@commitlint/cli": "^18.6.1",
"@commitlint/config-conventional": "^18.6.2",
"@eslint-community/eslint-plugin-eslint-comments": "^4.1.0",
"@types/jest": "^29.5.11",
"@types/jest": "^29.5.12",
"eslint": "^8.56.0",
"eslint-config-airbnb-base": "^15.0.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-jest": "^27.6.3",
"eslint-plugin-jsdoc": "^48.0.2",
"eslint-plugin-jest": "^27.9.0",
"eslint-plugin-jsdoc": "^48.1.0",
"eslint-plugin-promise": "^6.1.1",
"eslint-plugin-regexp": "^2.2.0",
"eslint-plugin-security": "^2.1.0",
"husky": "^9.0.6",
"eslint-plugin-security": "^2.1.1",
"husky": "^9.0.11",
"is-html": "^2.0.0",
"jest": "^29.7.0",
"jsdoc-to-markdown": "^8.0.0",
"jsdoc-to-markdown": "^8.0.1",
"license-checker": "^25.0.1",
"prettier": "^3.2.4",
"prettier": "^3.2.5",
"spdx-copyleft": "^1.0.0",
"typescript": "^5.3.3"
},
"dependencies": {
"semver": "^7.5.4",
"semver": "^7.6.0",
"upath": "^2.0.1"
}
}
12 changes: 6 additions & 6 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ const { joinSafe, normalizeTrim } = require("upath");
const errorMessages = {
3221225477: "Segmentation fault",
};
const rtfMagicNumber = "{\\rtf1";

// Cache immutable regex as they are expensive to create and garbage collect
const unrtfPathRegex = /(.+)unrtf/u;
// UnRTF version output is inconsistent between versions but always starts with the semantic version number
const unrtfVersionRegex = /^(\d{1,2}\.\d{1,2}\.\d{1,2})/u;
const rtfMagicNumberRegex = /^\{\\rtf/u;

/**
* @author Frazer Smith
Expand All @@ -34,7 +34,7 @@ function parseOptions(acceptedOptions, options, version) {
Object.keys(options).forEach((key) => {
if (Object.hasOwn(acceptedOptions, key)) {
// eslint-disable-next-line valid-typeof -- `type` is a string
if (typeof options[key] === acceptedOptions[key].type) {
if (acceptedOptions[key].type === typeof options[key]) {
// Skip boolean options if false
if (acceptedOptions[key].type === "boolean" && !options[key]) {
return;
Expand Down Expand Up @@ -213,7 +213,7 @@ class UnRTF {
throw new Error("File missing");
}
// Check for RTF specific magic number
if (!rtfMagicNumberRegex.test(buff.toString())) {
if (!buff.toString().startsWith(rtfMagicNumber)) {
throw new Error(
"File is not the correct media type, expected 'application/rtf'"
);
Expand Down Expand Up @@ -244,9 +244,7 @@ class UnRTF {
/* istanbul ignore else */
if (stdOut !== "") {
resolve(stdOut.trim());
} else if (stdErr !== "") {
reject(new Error(stdErr.trim()));
} else {
} else if (stdErr === "") {
reject(
new Error(
errorMessages[code] ||
Expand All @@ -255,6 +253,8 @@ class UnRTF {
)} exited with code ${code}`
)
);
} else {
reject(new Error(stdErr.trim()));
}
});
});
Expand Down
4 changes: 2 additions & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"moduleResolution": "NodeNext",
"outDir": "types",
"resolveJsonModule": true,
"target": "ES2022",
"target": "ES2022"
},
"include": ["src/index.js"],
"include": ["src/index.js"]
}

0 comments on commit dd64eaf

Please sign in to comment.