Skip to content

Commit 90df78d

Browse files
author
Jostein Kringlen
committed
feat(broadcast): encode broadcast url
1 parent fa816fa commit 90df78d

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

packages/broadcast/component.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,13 @@ export class FabricBroadcast extends FabricWebComponent {
1515

1616
// Generate url
1717
const dev = Boolean(this.getAttribute('dev'));
18-
const url = `https://${dev ? 'dev' : 'www'}.finn.no/broadcasts?path=${
19-
this.getAttribute('url') || window.location.href
20-
}`;
18+
const broadcastUrl = `https://${dev ? 'dev' : 'www'}.finn.no/broadcasts`;
19+
const pageUrl = this.getAttribute('url') || window.location.href;
20+
const url = new URL(broadcastUrl);
21+
url.searchParams.set('path', pageUrl);
2122

2223
// Fetch message
23-
const res = await (await fetch(url)).json();
24+
const res = await (await fetch(url.href)).json();
2425

2526
// If response exists
2627
if (res.length) {

0 commit comments

Comments
 (0)