Skip to content

Commit a26650b

Browse files
committed
Update to use built-in APIs instead of hard-coding query strings
1 parent 1e114dd commit a26650b

1 file changed

Lines changed: 3 additions & 4 deletions

File tree

src/plots/plots.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -215,10 +215,9 @@ plots.sendDataToCloud = function(gd, serverURL) {
215215
// the chart back to it once Cloud reports that authentication succeeded.
216216
// Pass the current page's origin as a query string so Cloud knows where to
217217
// send the CHART_AUTH_SUCCESS message back to.
218-
var uploadUrl = serverURL +
219-
(serverURL.indexOf('?') === -1 ? '?' : '&') +
220-
'origin=' + encodeURIComponent(window.location.origin);
221-
var cloudWindow = window.open(uploadUrl, '_blank');
218+
var uploadUrl = new URL(serverURL);
219+
uploadUrl.searchParams.set('origin', window.location.origin);
220+
var cloudWindow = window.open(uploadUrl.href, '_blank');
222221
if(!cloudWindow) {
223222
console.error('Unable to open Plotly Cloud (the popup may have been blocked)');
224223
gd.emit('plotly_exportfail');

0 commit comments

Comments
 (0)