Skip to content

Commit

Permalink
Fix page info collection in the content script (#69)
Browse files Browse the repository at this point in the history
* Use document base URL instead of current location
* Fix wrong condition in Apple mask icon detection
  • Loading branch information
filips123 committed Oct 28, 2021
1 parent 4a0b468 commit ee2b831
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions extension/src/content.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const manifestElement = document.querySelector('link[rel=manifest]')
let manifestUrl

if (manifestElement) {
manifestUrl = new URL(manifestElement.getAttribute('href'), window.location)
manifestUrl = new URL(manifestElement.getAttribute('href'), document.baseURI)
manifestUrl = manifestUrl.href
}

Expand All @@ -23,8 +23,8 @@ browser.runtime.onMessage.addListener((message, _, sendResponse) => {
icons: [...document.getElementsByTagName('link')]
.filter(link => link.hasAttribute('rel') && link.getAttribute('rel').toLowerCase().includes('icon'))
.map(link => ({
src: new URL(link.getAttribute('href'), window.location).href,
type: link.getAttribute('type') || isAppleMaskIcon(link) ? 'image/svg+xml' : null,
src: new URL(link.getAttribute('href'), document.baseURI).href,
type: link.getAttribute('type') || (isAppleMaskIcon(link) ? 'image/svg+xml' : null),
purpose: isAppleMaskIcon(link) ? 'monochrome' : 'any',
sizes: link.getAttribute('sizes') || ''
}))
Expand Down

0 comments on commit ee2b831

Please sign in to comment.