-
Notifications
You must be signed in to change notification settings - Fork 4
URI scheme: retrieve the file name for a zipped CellML file #391
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -428,12 +428,13 @@ function onSettingsMenu(): void { | |||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| // Open a file. | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| let globalDataUrlCounter = 0; | ||||||||||||||||||||||||||||||||
| let globalOmexDataUrlCounter = 0; | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| function openFile(fileFilePathOrFileContents: string | Uint8Array | File): void { | ||||||||||||||||||||||||||||||||
| // Check whether we were passed a ZIP-CellML data URL. | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| let dataUrlCounter = 0; | ||||||||||||||||||||||||||||||||
| let cellmlDataUrlFileName: string = ''; | ||||||||||||||||||||||||||||||||
agarny marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||||||||||||||||
| let omexDataUrlCounter: number = 0; | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| locCommon.zipCellmlDataUrl(fileFilePathOrFileContents).then((zipCellmlDataUriInfo: locCommon.IDataUriInfo) => { | ||||||||||||||||||||||||||||||||
| if (zipCellmlDataUriInfo.res) { | ||||||||||||||||||||||||||||||||
|
|
@@ -442,29 +443,41 @@ function openFile(fileFilePathOrFileContents: string | Uint8Array | File): void | |||||||||||||||||||||||||||||||
| severity: 'error', | ||||||||||||||||||||||||||||||||
| group: toastId.value, | ||||||||||||||||||||||||||||||||
| summary: 'Opening a file', | ||||||||||||||||||||||||||||||||
| detail: `${zipCellmlDataUriInfo.error}`, | ||||||||||||||||||||||||||||||||
| detail: zipCellmlDataUriInfo.error, | ||||||||||||||||||||||||||||||||
| life: TOAST_LIFE | ||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| return; | ||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| dataUrlCounter = ++globalDataUrlCounter; | ||||||||||||||||||||||||||||||||
| cellmlDataUrlFileName = zipCellmlDataUriInfo.fileName as string; | ||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||
| cellmlDataUrlFileName = zipCellmlDataUriInfo.fileName as string; | |
| cellmlDataUrlFileName = zipCellmlDataUriInfo.fileName ?? ''; |
Copilot
AI
Feb 4, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using as Uint8Array type assertion here is potentially unsafe. While the logic ensures that data should be defined when there's no error, TypeScript's type system indicates it's optional. Consider using a more defensive approach with optional chaining or an explicit check to ensure type safety and guard against potential future changes.
agarny marked this conversation as resolved.
Show resolved
Hide resolved
Copilot
AI
Feb 4, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using as Uint8Array type assertion here is potentially unsafe. While the logic ensures that data should be defined when there's no error, TypeScript's type system indicates it's optional. Consider using a more defensive approach with optional chaining or an explicit check to ensure type safety and guard against potential future changes.
| fileFilePathOrFileContents = combineArchiveDataUriInfo.data as Uint8Array; | |
| if (!(combineArchiveDataUriInfo.data instanceof Uint8Array)) { | |
| toast.add({ | |
| severity: 'error', | |
| group: toastId.value, | |
| summary: 'Opening a file', | |
| detail: 'Unexpected COMBINE archive data format.', | |
| life: TOAST_LIFE | |
| }); | |
| return; | |
| } | |
| fileFilePathOrFileContents = combineArchiveDataUriInfo.data; |
Uh oh!
There was an error while loading. Please reload this page.