Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix reading length of undefined at findFirstPage #47

Merged
merged 1 commit into from
Mar 17, 2021

Conversation

10ego
Copy link

@10ego 10ego commented Mar 16, 2021

TypeError: Cannot read property 'length' of undefined
    at exports.findFirstPage (/usr/lib/node_modules/@opendocsg/pdf2md/lib/util/page-number-functions.js:76:38)
    at parse (/usr/lib/node_modules/@opendocsg/pdf2md/lib/util/pdf.js:40:19)
    at async module.exports (/usr/lib/node_modules/@opendocsg/pdf2md/lib/pdf2md.js:22:18)
    at async createMarkdownFiles (/usr/lib/node_modules/@opendocsg/pdf2md/lib/pdf2md-cli.js:55:20)

Loop will continue until firstPage < keys.length, but since keys are zero-based, it leaves the final secondPage at undefined.
This PR attempts to fix it.

Counts until -1 of keys.length so that second page is not undefined
Copy link

@LoneRifle LoneRifle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm. Going forward, pdf-to-markdown - the package from which pdf2md is derived - may be undergoing major changes and would be more actively maintained than this package. I intend to deprecate this once pdf-to-markdown achieves feature parity.

@LoneRifle LoneRifle merged commit 2df1275 into opengovsg:master Mar 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants