-
Notifications
You must be signed in to change notification settings - Fork 319
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
Fix logic that determines if nifti file is compressed #1669
Conversation
Run & review this pull request in StackBlitz Codeflow. |
✅ Deploy Preview for cornerstone-3d-docs ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
@@ -25,7 +25,7 @@ export async function fetchArrayBuffer({ | |||
onHeader, | |||
loadFullVolume = false, | |||
}) { | |||
const isCompressed = url.endsWith('.gz'); | |||
const isCompressed = url.includes('.gz'); |
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.
but then how are you cleaning the url for the fetch?
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.
I don't need to clean the url. In my case, I use a signed URL and additional parameters are needed for authentication.
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.
Maybe use URL
api instead
const url = "https://toto.blob.core.windows.net/mycontainer/sample.nii.gz?sv=2019-10-10&ss=bfqt&srt=sco&sp=rwdlacupx&se=2020-07-17T10:09:48Z&st=2020-07-17T02:09:48Z&spr=https&sig=xxxxxxxxx";
const _url = new URL(url);
const isCompressed = _url.pathname.endsWith('.gz');
console.log(isCompressed);
const url = "https://myserver.com/sample.nii.gz";
const _url = new URL(url);
const isCompressed = _url.pathname.endsWith('.gz');
console.log(isCompressed);
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.
@daker good suggestion thanks! Updated the code.
Context
The logic which decides if remote nifti file is compressed or not has a flaw. It checks the end of the URL string for
.gz
extension. When url includes parameters/headers,.gz
extension appears in the middle of the string.For example, current logic will work for a URL like:
https://<some_address>/<filename>.nii.gz
but fail for a url likehttps://<some_address>/<filename>.nii.gz?<some_param>=<some_value>
.Changes & Results
This PR updates the logic to check for inclusion of the
.gz
extension anywhere in the string.Testing
Tested in a limited local environment and works as expected.
Checklist
PR
semantic-release format and guidelines.
Code
[] My code has been well-documented (function documentation, inline comments,
etc.)
[] I have run the
yarn build:update-api
to update the API documentation, and havecommitted the changes to this PR. (Read more here https://www.cornerstonejs.org/docs/contribute/update-api)
Public Documentation Updates
additions or removals.
Tested Environment