Skip to content

Commit

Permalink
enhance to support iframe url with query (#3)
Browse files Browse the repository at this point in the history
* enhance to support iframe url with search params
  • Loading branch information
MeganChenRc authored Aug 19, 2020
1 parent dcf92e0 commit 36c400f
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion packages/sync-host/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,14 @@ export class HostSync extends Sync {

this.iframe = iframe;

this.iframe.src = url + this.getState();
try {
const {origin, pathname, search} = new URL(url);
const updatedPathname = pathname === '/' ? '' : pathname;
this.iframe.src = `${origin}${updatedPathname}${this.getState()}${search}`;
} catch (error) {
this.iframe.src = url + this.getState();
console.error('Invalid URL of iframe', url);
}

!this.iframe['iFrameResizer'] &&
iFrameResize(
Expand Down

1 comment on commit 36c400f

@vercel
Copy link

@vercel vercel bot commented on 36c400f Aug 19, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.