Skip to content
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

Minor fix to prevent an error #92

Merged
merged 2 commits into from
Apr 8, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
20 changes: 11 additions & 9 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -304,16 +304,18 @@ const extension: JupyterFrontEndPlugin<void> = {
let visible = false;
if (widget) {
const firstItem = widget.selectedItems().next();
const basename = PathExt.basename(firstItem.path);
const splitName = basename.split('.');
let lastTwoParts = '';
if (splitName.length >= 2) {
lastTwoParts =
'.' + splitName.splice(splitName.length - 2, 2).join('.');
if (firstItem) {
const basename = PathExt.basename(firstItem.path);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

next() may return undefined.

const splitName = basename.split('.');
let lastTwoParts = '';
if (splitName.length >= 2) {
lastTwoParts =
'.' + splitName.splice(splitName.length - 2, 2).join('.');
}
visible =
allowedArchiveExtensions.indexOf(PathExt.extname(basename)) >= 0 ||
allowedArchiveExtensions.indexOf(lastTwoParts) >= 0;
}
visible =
allowedArchiveExtensions.indexOf(PathExt.extname(basename)) >= 0 ||
allowedArchiveExtensions.indexOf(lastTwoParts) >= 0;
}
return visible;
},
Expand Down