Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/plots/plots.js
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,12 @@ plots.sendDataToCloud = function(gd, serverURL) {

// Open the Cloud login page in a new tab. We keep a reference so we can post
// the chart back to it once Cloud reports that authentication succeeded.
var cloudWindow = window.open(serverURL, '_blank');
// Pass the current page's origin as a query string so Cloud knows where to
// send the CHART_AUTH_SUCCESS message back to.
var uploadUrl = serverURL +
(serverURL.indexOf('?') === -1 ? '?' : '&') +
'origin=' + encodeURIComponent(window.location.origin);
var cloudWindow = window.open(uploadUrl, '_blank');
Comment on lines +218 to +221

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@marthacryan Is there any built-in JS utility for handling URL params that we could use here?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

^ ah yeah that looks right, or the URL API more broadly. I think the most thorough logic would be:

  • parse serverURL into its base URL plus params
  • add origin: window.location.origin to params dict
  • re-generate full URL with new params

I suppose we could also just strip URL parameters from serverURL entirely since we don't currently have a use for them... but that might not even be any simpler.

if(!cloudWindow) {
console.error('Unable to open Plotly Cloud (the popup may have been blocked)');
gd.emit('plotly_exportfail');
Expand Down
Loading