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

Exactly one link in a paragraph with a bookmark causes failure to render page #254

Open
isaacwhite opened this issue Feb 26, 2021 · 0 comments
Assignees
Labels
bug Something isn't working

Comments

@isaacwhite
Copy link
Member

Context (Environment)

Within a particular paragraph, if there are exactly two links and one is a bookmark (not a normal link), the table of contents logic within Library can crash.

Expected Behavior

When a paragraph does not match expectations for table of contents, the link replacement should be ignored and left as-is.

To Reproduce

Within a single paragraph, add a bookmark. Then add a normal link later in the paragraph. Reload the library page and observe the following trace:

TypeError: Cannot read property \'match\' of undefined
  at checkForTableOfContents (/usr/src/app/server/formatter.js:156:25)
  at Node.$p.each (/usr/src/app/server/formatter.js:26:31)
  at initialize.exports.each (/usr/src/app/node_modules/cheerio/lib/api/traversing.js:300:24)
  at normalizeHtml (/usr/src/app/server/formatter.js:22:6)
  at getProcessedHtml (/usr/src/app/server/formatter.js:231:14)
  at Object.exports.getProcessedDocAttributes (/usr/src/app/server/formatter.js:243:25)
  at exports.fetchDoc 

Possible Solution

The table of contents logic should be made more robust, so that link tags without href attributes are ignored.

@isaacwhite isaacwhite added the bug Something isn't working label Feb 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants