@@ -52,12 +52,13 @@ function s3listv2(bucket: string, prefix: string) {
5252 } )
5353}
5454
55- function getS3SourceParts ( sourceId : string ) : SourcePart [ ] {
55+ function getSourceParts ( sourceId : string ) : SourcePart [ ] {
5656 const [ protocol , rest ] = sourceId . split ( '://' , 2 )
5757 const parts = rest
5858 ? [ `${ protocol } ://${ rest . split ( '/' , 1 ) [ 0 ] } ` , ...rest . split ( '/' ) . slice ( 1 ) ]
5959 : sourceId . split ( '/' )
6060 const sourceParts = [
61+ //{ 'text': '/', 'sourceId': '' },
6162 ...parts . map ( ( part , depth ) => {
6263 const slashSuffix = depth === parts . length - 1 ? '' : '/'
6364 return {
@@ -77,7 +78,7 @@ export function getHttpSource(sourceId: string, options?: {requestInit?: Request
7778 return undefined
7879 }
7980
80- const sourceParts = getS3SourceParts ( sourceId )
81+ const sourceParts = getSourceParts ( sourceId )
8182
8283 if ( sourceId . endsWith ( '/' ) ) {
8384 const url = new URL ( sourceId )
@@ -95,12 +96,11 @@ export function getHttpSource(sourceId: string, options?: {requestInit?: Request
9596 prefix,
9697 listFiles : ( ) => s3listv2 ( bucket , prefix ) . then ( items =>
9798 items
98- . filter ( item => Boolean ( item . key ) )
99+ . filter ( item => item . key !== undefined )
99100 . map ( item => {
100- if ( ! item . key ) return undefined
101- const isDirectory = item . key . endsWith ( '/' )
101+ const isDirectory = item . key ! . endsWith ( '/' )
102102 const itemSourceId = `https://${ bucket } .s3.amazonaws.com/${ item . key } `
103- let name = item . key . split ( '/' ) . pop ( ) ?? item . key
103+ let name = item . key ! . split ( '/' ) . pop ( ) || item . key
104104 if ( name && isDirectory ) {
105105 name = name . replace ( prefix , '' )
106106 }
0 commit comments