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

Fix logic that determines if nifti file is compressed #1669

Merged
merged 2 commits into from
Dec 6, 2024

Conversation

faridyagubbayli
Copy link
Contributor

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 like https://<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

  • [] My Pull Request title is descriptive, accurate and follows the
    semantic-release format and guidelines.

Code

Public Documentation Updates

  • [] The documentation page has been updated as necessary for any public API
    additions or removals.

Tested Environment

  • [] "OS:
  • [] "Node version:
  • [] "Browser:

Copy link

stackblitz bot commented Dec 4, 2024

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

Copy link

netlify bot commented Dec 4, 2024

Deploy Preview for cornerstone-3d-docs ready!

Name Link
🔨 Latest commit 4af9f6e
🔍 Latest deploy log https://app.netlify.com/sites/cornerstone-3d-docs/deploys/67530615377e6800086c90f8
😎 Deploy Preview https://deploy-preview-1669--cornerstone-3d-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

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');
Copy link
Member

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?

Copy link
Contributor Author

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.

Copy link
Contributor

@daker daker Dec 5, 2024

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);

Copy link
Contributor Author

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.

@sedghi sedghi merged commit 48e5805 into cornerstonejs:main Dec 6, 2024
26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants