Skip to content

Commit

Permalink
fix: call loadUrl when opening new windows from links
Browse files Browse the repository at this point in the history
  • Loading branch information
codebytere committed May 10, 2022
1 parent 5391211 commit 1667e42
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions lib/browser/guest-window-manager.ts
Expand Up @@ -78,6 +78,19 @@ export function openGuestWindow ({ event, embedder, guest, referrer, disposition
...browserWindowOptions
});

if (!guest) {
// When we open a new window from a link (via OpenURLFromTab),
// the browser process is responsible for initiating navigation
// in the new window.
window.loadURL(url, {
httpReferrer: referrer,
...(postData && {
postData,
extraHeaders: formatPostDataHeaders(postData as Electron.UploadRawData[])
})
});
}

handleWindowLifecycleEvents({ embedder, frameName, guest: window, outlivesOpener });

embedder.emit('did-create-window', window, { url, frameName, options: browserWindowOptions, disposition, referrer, postData });
Expand Down Expand Up @@ -243,6 +256,15 @@ export function makeWebPreferences ({ embedder, secureOverrideWebPreferences = {
};
}

function formatPostDataHeaders (postData: PostData) {
if (!postData) return;

const { contentType, boundary } = parseContentTypeFormat(postData);
if (boundary != null) { return `content-type: ${contentType}; boundary=${boundary}`; }

return `content-type: ${contentType}`;
}

const MULTIPART_CONTENT_TYPE = 'multipart/form-data';
const URL_ENCODED_CONTENT_TYPE = 'application/x-www-form-urlencoded';

Expand Down

0 comments on commit 1667e42

Please sign in to comment.