How to use the @jupyterlab/coreutils.URLExt.join function in @jupyterlab/coreutils

To help you get started, we’ve selected a few @jupyterlab/coreutils examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github krassowski / jupyterlab-lsp / packages / jupyterlab-lsp / src / connection_manager.ts View on Github external
private connect_socket(options: ISocketConnectionOptions): LSPConnection {
    let { virtual_document, language } = options;

    const wsBase = PageConfig.getBaseUrl().replace(/^http/, 'ws');
    const rootUri = PageConfig.getOption('rootUri');
    const documentUri = URLExt.join(rootUri, virtual_document.uri);
    const serverUri = URLExt.join('ws://jupyter-lsp', language);
    let socket = new WebSocket(URLExt.join(wsBase, 'lsp', language));

    let connection = new LSPConnection({
      languageId: language,
      serverUri,
      rootUri,
      documentUri,
      documentText: () => {
        // NOTE: Update is async now and this is not really used, as an alternative method
        // which is compatible with async is used.
        // This should be only used in the initialization step.
        // if (main_connection.isConnected) {
        //  console.warn('documentText is deprecated for use in JupyterLab LSP');
        // }
        return virtual_document.value;
      }
    }).connect(socket);
github jupyterlab / jupyterlab / packages / services / src / contents / index.ts View on Github external
getDownloadUrl(localPath: string): Promise {
    let baseUrl = this.serverSettings.baseUrl;
    let url = URLExt.join(baseUrl, FILES_URL, URLExt.encodeParts(localPath));
    const xsrfTokenMatch = document.cookie.match('\\b_xsrf=([^;]*)\\b');
    if (xsrfTokenMatch) {
      const fullurl = new URL(url);
      fullurl.searchParams.append('_xsrf', xsrfTokenMatch[1]);
      url = fullurl.toString();
    }
    return Promise.resolve(url);
  }
github jupyterlab / jupyterlab / packages / services / src / terminal / default.ts View on Github external
export function getServiceUrl(baseUrl: string): string {
    return URLExt.join(baseUrl, TERMINAL_SERVICE_URL);
  }
github dask / dask-labextension / src / dashboard.tsx View on Github external
private _updateUrl(): void {
    if (!this.item || !this.dashboardUrl) {
      this.content.url = '';
      return;
    }
    this.content.url = URLExt.join(this.dashboardUrl, this.item!.route);
  }
github jupyterlab / jupyterlab-data-explorer / jupyterlab / packages / services / src / kernel / default.ts View on Github external
export async function getKernelModel(
    id: string,
    settings?: ServerConnection.ISettings
  ): Promise {
    settings = settings || ServerConnection.makeSettings();
    let url = URLExt.join(
      settings.baseUrl,
      KERNEL_SERVICE_URL,
      encodeURIComponent(id)
    );
    let response = await ServerConnection.makeRequest(url, {}, settings);
    if (response.status !== 200) {
      throw new ServerConnection.ResponseError(response);
    }
    let data = await response.json();
    validate.validateModel(data);
    return data;
  }
github jupyterlab / jupyterlab / packages / services / src / session / restapi.ts View on Github external
export async function startSession(
  options: Session.ISessionOptions,
  settings: ServerConnection.ISettings = ServerConnection.makeSettings()
): Promise {
  let url = URLExt.join(settings.baseUrl, SESSION_SERVICE_URL);
  let init = {
    method: 'POST',
    body: JSON.stringify(options)
  };
  let response = await ServerConnection.makeRequest(url, init, settings);
  if (response.status !== 201) {
    throw new ServerConnection.ResponseError(response);
  }
  let data = await response.json();
  updateLegacySessionModel(data);
  validateModel(data);
  return data;
}
github jupyterlab / jupyterlab-data-explorer / jupyterlab / packages / notebook-extension / src / index.ts View on Github external
execute: args => {
      const current = getCurrent(args);

      if (!current) {
        return;
      }

      const notebookPath = URLExt.encodeParts(current.context.path);
      const url =
        URLExt.join(
          services.serverSettings.baseUrl,
          'nbconvert',
          args['format'] as string,
          notebookPath
        ) + '?download=true';
      const child = window.open('', '_blank');
      const { context } = current;

      child.opener = null;
      if (context.model.dirty && !context.model.readOnly) {
        return context.save().then(() => {
          child.location.assign(url);
        });
      }

      return new Promise(resolve => {
github timkpaine / lantern / src / lantern.ts View on Github external
execute: args => {
      const current = getCurrent(args);

      if (!current) {
        return;
      }

      const notebookPath = URLExt.encodeParts(current.context.path);
      const url = URLExt.join(
        services.serverSettings.baseUrl,
        'nbconvert',
        'html_hidecode',
        notebookPath
      ) + '?download=true';
      const child = window.open('', '_blank');
      const { context } = current;

      if (context.model.dirty && !context.model.readOnly) {
        return context.save().then(() => { child.location.assign(url); });
      }

      return new Promise((resolve) => {
        child.location.assign(url);
        resolve(undefined);
      });
github jupyterlab / jupyterlab / packages / services / src / terminal / default.ts View on Github external
map(data, item => {
            return URLExt.join(url, item.name);
          })
        );
github jupyterlab / jupyterlab / packages / services / src / session / default.ts View on Github external
export function getSessionUrl(baseUrl: string, id: string): string {
    return URLExt.join(baseUrl, SESSION_SERVICE_URL, id);
  }