Skip to content

Commit ada384e

Browse files
authoredNov 18, 2023
fix(state_share): new method to include credentials for state sharing (#500)
* fix(state_share): new method to include credentials for state sharing due to chrome introducing restrictions on setting protocols using the URL API * cleaned up state url credential fix code
1 parent 4717511 commit ada384e

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed
 

‎src/neuroglancer/datasource/state_share.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,9 @@ export class StateShare extends RefCounted { // call it a widget? no because it
7272
body: JSON.stringify(viewer.state.toJSON())
7373
}, responseJson)
7474
.then((res) => {
75-
const stateUrl = new URL(res);
76-
stateUrl.protocol = protocol; // copy protocol in case it contains authentication type
77-
const link = `${window.location.origin}/#!${stateUrl}`;
75+
const stateUrlProtcol = new URL(res).protocol;
76+
const stateUrlWithoutProtocol = res.substring(stateUrlProtcol.length);
77+
const link = `${window.location.origin}/#!${protocol}${stateUrlWithoutProtocol}`;
7878
navigator.clipboard.writeText(link).then(() => {
7979
StatusMessage.showTemporaryMessage('Share link copied to clipboard');
8080
});

0 commit comments

Comments
 (0)
Please sign in to comment.