File tree Expand file tree Collapse file tree 2 files changed +19
-13
lines changed Expand file tree Collapse file tree 2 files changed +19
-13
lines changed Original file line number Diff line number Diff line change @@ -6,18 +6,6 @@ import "xterm/css/xterm.css";
66import { Progress , PROGRESS_STATES } from "./Progress.jsx" ;
77import { Spec } from "../spec.js" ;
88
9- /**
10- *
11- * @param {string } serverUrl
12- * @param {string } token
13- * @param {string } urlPath
14- */
15- function redirectToRunningServer ( serverUrl , token , urlPath ) {
16- const redirectUrl = new URL ( urlPath , serverUrl ) ;
17- redirectUrl . searchParams . append ( "token" , token ) ;
18- window . location . href = redirectUrl . toString ( ) ;
19- }
20-
219/**
2210 *
2311 * @param {URL } baseUrl
@@ -64,7 +52,11 @@ async function buildImage(
6452 case "ready" : {
6553 setProgressState ( PROGRESS_STATES . SUCCESS ) ;
6654 image . close ( ) ;
67- redirectToRunningServer ( data . url , data . token , spec . launchSpec . urlPath ) ;
55+ const serverUrl = new URL ( data . url ) ;
56+ window . location . href = spec . launchSpec . getJupyterServerRedirectUrl (
57+ serverUrl ,
58+ data . token ,
59+ ) ;
6860 console . log ( data ) ;
6961 break ;
7062 }
Original file line number Diff line number Diff line change @@ -9,6 +9,20 @@ export class LaunchSpec {
99 this . urlPath = this . urlPath . replace ( / ^ \/ * / , "" ) ;
1010 }
1111
12+ /**
13+ * Return a URL to redirect user to for use with this launch specification
14+ *
15+ * @param {URL } serverUrl Fully qualified URL to a running Jupyter Server
16+ * @param {string } token Authentication token to pass to the Jupyter Server
17+ *
18+ * @returns {URL }
19+ */
20+ getJupyterServerRedirectUrl ( serverUrl , token ) {
21+ const redirectUrl = new URL ( this . urlPath , serverUrl ) ;
22+ redirectUrl . searchParams . append ( "token" , token ) ;
23+ return redirectUrl ;
24+ }
25+
1226 /**
1327 * Create a LaunchSpec from given query parameters in the URL
1428 *
You can’t perform that action at this time.
0 commit comments