Skip to content

Commit

Permalink
Improve current url detection for blacklist, to work for nested ifram…
Browse files Browse the repository at this point in the history
…es with no/different urls.

Only respond to the status event in the dashboard.
  • Loading branch information
ghinda committed Feb 15, 2024
1 parent 8a3c4a5 commit 8deb833
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/content/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,20 @@ import {setup as setupPage, destroy as destroyPage} from './page/page-parent.js'
import {setup as setupAttachments, destroy as destroyAttachments} from './attachments/attachments.js'
import {setup as setupDashboardEvents, destroy as destroyDashboardEvents} from './dashboard-events-client.js'

const currentUrl = window.location.href
function getParentUrl () {
let url = window.location.href
if (window !== window.parent) {
try {
url = window.parent.location.href
} catch (err) {
// iframe from different domain
}
}

return url
}

const currentUrl = getParentUrl()

const blacklistPrivate = [
'.briskine.com',
Expand Down
4 changes: 4 additions & 0 deletions src/content/status.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ function respondToStatus () {
const requestEvent = `${config.eventStatus}-request`

export function setup () {
if (window.location.origin !== config.functionsUrl) {
return
}

document.addEventListener(requestEvent, respondToStatus)
}

Expand Down

0 comments on commit 8deb833

Please sign in to comment.