Skip to content

Commit

Permalink
feat: add check for canonical url presence when sharing
Browse files Browse the repository at this point in the history
  • Loading branch information
filipboev committed Jul 27, 2021
1 parent f002af2 commit 38e90d5
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/bridge/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ const extractDocMetadata = () => {
// get defaults first
const title = document.title || ''
const description = getElementContentByPropSelector({ element: 'meta', prop: 'name', value: 'description' }) || ''
const url = document.location.href || ''
const cannonicalUrl = getElementContentByPropSelector({ element: 'link', prop: 'rel', value: 'canonical', attribute: 'href' })
const url = cannonicalUrl || document.location.href
// check for LDJson linked data, return that if present
const LDJson = getElementContentByPropSelector({ element: 'script', prop: 'type', value: 'application/ld+json', innerHtml: true })
if (LDJson) {
Expand Down

0 comments on commit 38e90d5

Please sign in to comment.