Skip to content

Commit

Permalink
Merge pull request #953 from geoadmin/bug-PB-703-iframe-embed
Browse files Browse the repository at this point in the history
PB-703: Fix /index.html share embed - #patch
  • Loading branch information
ltshb authored Jun 25, 2024
2 parents 54b3aed + 8a39a7d commit 50ba2c2
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
6 changes: 3 additions & 3 deletions src/utils/__tests__/utils.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ describe('utils', () => {

describe('transformUrlMapToEmbed', () => {
it('transform #/map to #/embed', () => {
expect(transformUrlMapToEmbed('https://map.geo.admin.ch/index.html#/map')).to.equal(
'https://map.geo.admin.ch/index.html#/embed'
)
expect(transformUrlMapToEmbed('https://map.geo.admin.ch/#/map')).to.equal(
'https://map.geo.admin.ch/#/embed'
)
Expand All @@ -73,9 +76,6 @@ describe('utils', () => {
'https://map.geo.admin.ch/#/map/view',
'https://map.geo.admin.ch/#/hello',
'https://map.geo.admin.ch/#/hello?lang=de',
'https://map.geo.admin.ch/map',
'https://map.geo.admin.ch/map?de',
'https://map.geo.admin.ch/test#/map',
]
urls.forEach((url) => expect(transformUrlMapToEmbed(url)).to.equal(url))
})
Expand Down
4 changes: 1 addition & 3 deletions src/utils/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -219,9 +219,7 @@ export function parseUrlHashQuery(url) {
*/
export function transformUrlMapToEmbed(url) {
const { urlObj, hash, query } = parseUrlHashQuery(url)
if (urlObj.pathname !== '/') {
return url
}
log.debug(`Transform url from map to embed hash=${hash}`, urlObj)
if (hash === '#/map') {
urlObj.hash = `#/embed${query}`
}
Expand Down

0 comments on commit 50ba2c2

Please sign in to comment.