@@ -16,6 +16,7 @@ import {
1616 RegistryVarsEntry ,
1717} from '../../../../common/types' ;
1818import { PackageInvalidArchiveError , PackageUnsupportedMediaTypeError } from '../../../errors' ;
19+ import { pkgToPkgKey } from '../registry' ;
1920import { cacheGet , cacheSet , setArchiveFilelist } from '../registry/cache' ;
2021import { unzipBuffer , untarBuffer , ArchiveEntry } from '../registry/extract' ;
2122
@@ -110,7 +111,8 @@ function parseAndVerifyArchive(paths: string[]): ArchivePackage {
110111 }
111112
112113 // Package name and version from the manifest must match those from the toplevel directory
113- if ( toplevelDir !== `${ manifest . name } -${ manifest . version } ` ) {
114+ const pkgKey = pkgToPkgKey ( { name : manifest . name , version : manifest . version } ) ;
115+ if ( toplevelDir !== pkgKey ) {
114116 throw new PackageInvalidArchiveError (
115117 `Name ${ manifest . name } and version ${ manifest . version } do not match top-level directory ${ toplevelDir } `
116118 ) ;
@@ -147,11 +149,12 @@ function parseAndVerifyDatasets(
147149 // A data stream is made up of a subdirectory of name-version/data_stream/, containing a manifest.yml
148150 let dataStreamPaths : string [ ] = [ ] ;
149151 const dataStreams : RegistryDataStream [ ] = [ ] ;
152+ const pkgKey = pkgToPkgKey ( { name : pkgName , version : pkgVersion } ) ;
150153
151154 // pick all paths matching name-version/data_stream/DATASTREAM_PATH/...
152155 // from those, pick all unique data stream paths
153156 paths
154- . filter ( ( path ) => path . startsWith ( `${ pkgName } - ${ pkgVersion } /data_stream/` ) )
157+ . filter ( ( path ) => path . startsWith ( `${ pkgKey } /data_stream/` ) )
155158 . forEach ( ( path ) => {
156159 const parts = path . split ( '/' ) ;
157160 if ( parts . length > 2 && parts [ 2 ] ) dataStreamPaths . push ( parts [ 2 ] ) ;
@@ -160,7 +163,7 @@ function parseAndVerifyDatasets(
160163 dataStreamPaths = uniq ( dataStreamPaths ) ;
161164
162165 dataStreamPaths . forEach ( ( dataStreamPath ) => {
163- const manifestFile = `${ pkgName } - ${ pkgVersion } /data_stream/${ dataStreamPath } /manifest.yml` ;
166+ const manifestFile = `${ pkgKey } /data_stream/${ dataStreamPath } /manifest.yml` ;
164167 const manifestBuffer = cacheGet ( manifestFile ) ;
165168 if ( ! paths . includes ( manifestFile ) || ! manifestBuffer ) {
166169 throw new PackageInvalidArchiveError (
0 commit comments