URI scheme: retrieve the file name for a zipped CellML file#391
URI scheme: retrieve the file name for a zipped CellML file#391agarny merged 4 commits intoopencor:mainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR addresses issue #390 by enhancing the URI scheme to display the actual file name for zipped CellML files instead of generic identifiers like "Data URL #xxx". For COMBINE archives, it now uses "OMEX #xxx" as a more descriptive identifier.
Changes:
- Modified
IDataUriInfointerface to include afileNamefield for storing extracted file names from zipped CellML files - Updated
filePath()andfile()functions to accept a file name parameter and use it in the naming logic - Renamed variables from generic "dataUrl" prefixes to more specific "cellmlDataUrl" and "omexDataUrl" prefixes for clarity
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 12 comments.
| File | Description |
|---|---|
| src/renderer/src/common/locCommon.ts | Added fileName field to IDataUriInfo interface; updated return statements in data URL processing functions; modified filePath and file functions to accept and use file name parameter |
| src/renderer/src/components/OpenCOR.vue | Introduced separate tracking for CellML file names and OMEX counters; updated function calls to pass new parameters |
| package.json | Version bump to 0.20260204.1 |
| src/renderer/package.json | Version bump to 0.20260204.1 |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 4 out of 4 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| } | ||
|
|
||
| dataUrlCounter = ++globalDataUrlCounter; | ||
| cellmlDataUrlFileName = zipCellmlDataUriInfo.fileName as string; |
There was a problem hiding this comment.
Using as string type assertion here is potentially unsafe. While the logic ensures that fileName should be defined when there's no error, TypeScript's type system indicates it's optional. Consider using optional chaining with a default value for better type safety: cellmlDataUrlFileName = zipCellmlDataUriInfo.fileName ?? ''; This makes the code more defensive against potential future changes in the zipCellmlDataUrl function.
| cellmlDataUrlFileName = zipCellmlDataUriInfo.fileName as string; | |
| cellmlDataUrlFileName = zipCellmlDataUriInfo.fileName ?? ''; |
|
|
||
| dataUrlCounter = ++globalDataUrlCounter; | ||
| cellmlDataUrlFileName = zipCellmlDataUriInfo.fileName as string; | ||
| fileFilePathOrFileContents = zipCellmlDataUriInfo.data as Uint8Array; |
There was a problem hiding this comment.
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.
| } | ||
|
|
||
| omexDataUrlCounter = ++globalOmexDataUrlCounter; | ||
| fileFilePathOrFileContents = combineArchiveDataUriInfo.data as Uint8Array; |
There was a problem hiding this comment.
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; |
Fixes #390.