Skip to content
Open
Show file tree
Hide file tree
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
9 changes: 4 additions & 5 deletions packages/collaboration/src/sharedlink.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,12 +134,11 @@ export async function showSharedLinkDialog({
serverOwner = PageConfig.getOption('hubServerUser');
serverName = PageConfig.getOption('hubServerName');
// Prepare the Hub API URL
const protocol = window.location.protocol;
const hostname =
PageConfig.getOption('hubHost') || window.location.hostname;
const port = window.location.port;
// hubHost is the full Origin (`proto://hostname:port`)
// or an empty string, making hubApiUrl an absolute path on the current origin
const hubHost = PageConfig.getOption('hubHost') || '';
const prefix = PageConfig.getOption('hubPrefix');
hubApiUrl = `${protocol}//${hostname}:${port}${prefix}api`;
hubApiUrl = `${hubHost}${prefix}api`;
// Check Hub version for share compatibility (>= 5.0)
const response = await fetch(hubApiUrl, {
// A GET request on base API url returns the Hub version
Expand Down
2 changes: 1 addition & 1 deletion ui-tests/tests/hub-share.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ test('should open JupyterHub sharing dialog', async ({ page }) => {
document.body.dataset['hubUser'] = 'jovyan';
document.body.dataset['hubServerUser'] = 'jovyan';
document.body.dataset['hubServerName'] = 'my-server';
document.body.dataset['hubHost'] = 'localhost';
document.body.dataset['hubHost'] = '';
document.body.dataset['hubPrefix'] = '/hub/';
});

Expand Down
Loading