Skip to content

Commit

Permalink
fix(zarrmultiscalespatialimage): support Zarr stores not ending in .z…
Browse files Browse the repository at this point in the history
…arr (#721)

* fix(zarrmultiscalespatialimage): support Zarr stores not ending in .zarr

The isZarr regex was updated to support .zarr/image, besides just .zarr and DANDI /zarr/.

fix #719

* fix(ZarrMultiscaleSpatialImage): add word boundary to isZarr regex

---------

Co-authored-by: Paul Elliott <paul.elliott@kitware.com>
  • Loading branch information
berombau and PaulHax authored Dec 20, 2023
1 parent 50332ae commit 2138166
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/IO/ZarrMultiscaleSpatialImage.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { getComponentType } from './dtypeUtils'
import { MAX_CONCURRENCY } from '../Context/ViewerMachineContext'

// ends with zarr and optional nested image name like foo.zarr/image1
export const isZarr = url => /zarr((\/)[\w-]+\/?)?$/.test(url)
export const isZarr = url => /\w[./]zarr\b/.test(url)

const TCZYX = Object.freeze(['t', 'c', 'z', 'y', 'x'])

Expand Down
18 changes: 13 additions & 5 deletions test/zarrTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,22 @@ test('Test isZarr', t => {
'real url'
)

t.false(isZarr('foo.asdf'), 'not when .asdf extension')
t.true(isZarr('https://site.com/zarr/a/b'), 'deep nested image')
t.true(
isZarr('https://site.com/foo.zarr/a/b'),
'deep nested image with zarr as extension'
)

t.false(isZarr('zarr.asdf'), 'not when .asdf extension')
t.false(
isZarr('foo.zarr.asdf/asdf'),
isZarr('barzarr.asdf'),
'not when .asdf extension withfilename barzarr'
)
t.false(
isZarr('barzarr.asdf/asdf'),
'not when .asdf extension and has suffix'
)

t.false(isZarr('foo.zarr.asdf.baz'), '.baz suffix')
t.false(isZarr('foo.zarrX.png'), '.zarrX extension, not .zarr')
t.false(isZarr('foo.zarrX'), '.zarrX extension, not .zarr')

t.end()
})
Expand Down

0 comments on commit 2138166

Please sign in to comment.