Skip to content

Don't remove URL parameters after loading #18

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
13 changes: 1 addition & 12 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {

import { showErrorMessage } from '@jupyterlab/apputils';

import { PageConfig, PathExt, URLExt } from '@jupyterlab/coreutils';
import { PathExt } from '@jupyterlab/coreutils';

import { IDefaultFileBrowser } from '@jupyterlab/filebrowser';

Expand Down Expand Up @@ -53,15 +53,6 @@ const plugin: JupyterFrontEndPlugin<void> = {
}
const urls = paths.map(path => decodeURIComponent(path));

// handle the route and remove the fromURL parameter
const handleRoute = () => {
const url = new URL(URLExt.join(PageConfig.getBaseUrl(), request));
// only remove the fromURL parameter
url.searchParams.delete(paramName);
const { pathname, search } = url;
router.navigate(`${pathname}${search}`, { skipRouting: true });
};

// fetch the file from the URL and open it with the docmanager
const fetchAndOpen = async (url: string): Promise<void> => {
let type = '';
Expand Down Expand Up @@ -108,13 +99,11 @@ const plugin: JupyterFrontEndPlugin<void> = {
if (match?.includes('/notebooks') || match?.includes('/edit')) {
const [first] = urls;
await fetchAndOpen(first);
handleRoute();
return;
}

app.restored.then(async () => {
await Promise.all(urls.map(url => fetchAndOpen(url)));
handleRoute();
});
}
});
Expand Down