Skip to content

Commit

Permalink
Fix possibly null on getPostID
Browse files Browse the repository at this point in the history
  • Loading branch information
Jack-Works committed Jul 3, 2019
1 parent a0052bd commit 9680026
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/extension/content-script/injections/Posts.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,10 @@ function getPostBy(node: DomProxy) {
}
function getPostID(node: DomProxy) {
if (isMobile) {
const idElement = node.current.querySelector('abbr')!.closest('a')!
const abbr = node.current.querySelector('abbr')
if (!abbr) return null
const idElement = abbr.closest('a')
if (!idElement) return null
const id = new URL(idElement.href)
return id.searchParams.get('id') || ''
} else {
Expand Down

0 comments on commit 9680026

Please sign in to comment.