This repository was archived by the owner on Feb 12, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +14
-1
lines changed Expand file tree Collapse file tree 1 file changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -130,14 +130,19 @@ module.exports = function files (self) {
130
130
throw new Error ( 'You must supply an ipfsPath' )
131
131
}
132
132
133
+ ipfsPath = normalizePath ( ipfsPath )
134
+ const pathComponents = ipfsPath . split ( '/' )
135
+ const restPath = normalizePath ( pathComponents . slice ( 1 ) . join ( '/' ) )
136
+ const filterFile = ( file ) => ( restPath && file . path === restPath ) || ( file . path === ipfsPath )
137
+
133
138
const d = deferred . source ( )
134
139
135
140
pull (
136
141
exporter ( ipfsPath , self . _ipldResolver ) ,
137
142
pull . collect ( ( err , files ) => {
138
143
if ( err ) { return d . abort ( err ) }
139
144
if ( files && files . length > 1 ) {
140
- files = files . filter ( ( file ) => file . path === ipfsPath )
145
+ files = files . filter ( filterFile )
141
146
}
142
147
if ( ! files || ! files . length ) {
143
148
return d . abort ( new Error ( 'No such file' ) )
@@ -286,3 +291,11 @@ module.exports = function files (self) {
286
291
lsPullStreamImmutable : _lsPullStreamImmutable
287
292
}
288
293
}
294
+
295
+ function normalizePath ( path ) {
296
+ if ( path . charAt ( path . length - 1 ) === '/' ) {
297
+ path = path . substring ( 0 , path . length - 1 )
298
+ }
299
+
300
+ return path
301
+ }
You can’t perform that action at this time.
0 commit comments