Skip to content

Commit

Permalink
Allow tools to access parent's url
Browse files Browse the repository at this point in the history
  • Loading branch information
Dianliang233 committed Jul 10, 2024
1 parent 6d0a8b9 commit c08bd00
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
2 changes: 1 addition & 1 deletion mediawiki/loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ mw.hook('wikipage.content').add(() => {
}

// eslint-disable-next-line no-undef
const url = `/tools/${type}/#?id=${id}&locale=${mw.config.get('wgPageContentLanguage')}&origin=${encodeURIComponent(window.location.origin)}`
const url = `/tools/${type}/#?id=${id}&locale=${mw.config.get('wgPageContentLanguage')}&url=${encodeURIComponent(window.location.href)}`

if (localStorage.getItem('mcwCalcLocal') === 'true') {
console.log('You are in development environment and tools are loaded from localhost.')
Expand Down
5 changes: 2 additions & 3 deletions src/utils/iframe.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
export function parentOrigin(): string {
const paramOrigin = new URLSearchParams(window.location.hash.substring(2)).get('origin')
if (paramOrigin) return paramOrigin
const paramUrl = new URLSearchParams(window.location.hash.substring(2)).get('url')

return new URL(document.referrer || location.href).origin
return new URL(paramUrl || document.referrer || location.href).origin
}

0 comments on commit c08bd00

Please sign in to comment.