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: some page has no href for "issue". #3422

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Wenzhi-Ding
Copy link
Contributor

Comment on lines +98 to +101
const href = issueNode?.parentNode?.href || "";
const issueMatch = href.match(/\/issues\/\d+\/(\d+)\/(\d+)$/);
item.volume = issueMatch ? issueMatch[1] : "";
item.issue = issueMatch ? issueMatch[2] : "";
Copy link
Member

Choose a reason for hiding this comment

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

  • We generally avoid const for things that aren't actually static constants (house style, I guess)
  • It should be clearer that everything following the first line is a no-op if it doesn't match
  • We already checked for issueNode's existence, and it definitely does have a parent (it isn't the Document node)
Suggested change
const href = issueNode?.parentNode?.href || "";
const issueMatch = href.match(/\/issues\/\d+\/(\d+)\/(\d+)$/);
item.volume = issueMatch ? issueMatch[1] : "";
item.issue = issueMatch ? issueMatch[2] : "";
let href = issueNode.parentNode.href;
if (href) {
let issueMatch = href.match(/\/issues\/\d+\/(\d+)\/(\d+)$/);
if (issueMatch) {
item.volume = issueMatch[1];
item.issue = issueMatch[2];
}
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants