Skip to content

Commit

Permalink
fix(index): do not pass false boolean options to binary
Browse files Browse the repository at this point in the history
  • Loading branch information
Fdawgs committed May 13, 2023
1 parent 639fcda commit 44fddd2
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ function parseOptions(acceptedOptions, options, version) {
if (Object.prototype.hasOwnProperty.call(acceptedOptions, key)) {
// eslint-disable-next-line valid-typeof
if (typeof options[key] === acceptedOptions[key].type) {
// Skip boolean options if false
if (acceptedOptions[key].type === "boolean" && !options[key]) {
return;
}
args.push(acceptedOptions[key].arg);
} else {
invalidArgs.push(
Expand Down
24 changes: 24 additions & 0 deletions src/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,30 @@ describe("Convert function", () => {
expect(isHtml(res)).toBe(true);
});

it("Converts RTF file to HTML if the `output*` option is set to false", async () => {
const outputOptions = [
"outputHtml",
"outputLatex",
"outputText",
"outputVt",
];

const unRtf = new UnRTF(testBinaryPath);

await Promise.all(
outputOptions.map(async (option) => {
const options = {
noPictures: true,
[option]: false,
};

const res = await unRtf.convert(file, options);

expect(isHtml(res)).toBe(true);
})
);
});

it("Converts RTF file to HTML without storing images", async () => {
const unRtf = new UnRTF(testBinaryPath);
const options = {
Expand Down

0 comments on commit 44fddd2

Please sign in to comment.