Skip to content
This repository was archived by the owner on Oct 16, 2020. It is now read-only.

Commit 54304b8

Browse files
autozimufelixfbecker
authored andcommitted
fix(fs): encode glob returned path (#469)
Fixes #422
1 parent 7bda4cb commit 54304b8

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

src/fs.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ export class LocalFileSystem implements FileSystem {
7878
follow: true,
7979
})
8080
globber.on('match', (file: string) => {
81-
subscriber.next(normalizeUri(base + file))
81+
subscriber.next(file)
8282
})
8383
globber.on('error', (err: any) => {
8484
subscriber.error(err)
@@ -89,6 +89,12 @@ export class LocalFileSystem implements FileSystem {
8989
return () => {
9090
globber.abort()
9191
}
92+
}).map(file => {
93+
const encodedPath = file
94+
.split('/')
95+
.map(encodeURIComponent)
96+
.join('/')
97+
return normalizeUri(base + encodedPath)
9298
})
9399
}
94100

src/test/memfs.test.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,14 @@ describe('memfs.ts', () => {
1818
sinon.assert.calledOnce(listener)
1919
sinon.assert.calledWithExactly(listener, 'file:///foo/bar.txt', undefined)
2020
})
21+
it('should add just a URI and emit an event when URI has encoded char', () => {
22+
const listener = sinon.spy()
23+
const fs = new InMemoryFileSystem('/')
24+
fs.on('add', listener)
25+
fs.add('file:///foo/%25bar.txt')
26+
sinon.assert.calledOnce(listener)
27+
sinon.assert.calledWithExactly(listener, 'file:///foo/%25bar.txt', undefined)
28+
})
2129
it('should add content for a URI and emit an event', () => {
2230
const listener = sinon.spy()
2331
const fs = new InMemoryFileSystem('/')

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy