Skip to content

Commit 4ff6f98

Browse files
committed
fix: remove trailing slashes for fs.open to address Node v23 bug
Ref: nodejs/node#55527
1 parent bfa52bf commit 4ff6f98

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

st.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,10 @@ class Mount {
223223

224224
// get a path from a url
225225
getPath (u) {
226-
return path.join(this.path, u)
226+
// trailing slash removal to fix Node.js v23 bug
227+
// https://github.com/nodejs/node/pull/55527
228+
// can be removed when this is resolved and released
229+
return path.join(this.path, u.replace(/\/+$/, ''))
227230
}
228231

229232
// get a url from a path

test/basic.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,14 @@ test('multiball!', (t) => {
9797
}
9898
})
9999

100+
test('trailing slash', (t) => {
101+
req('/test/test/fixtures/', (er, res, body) => {
102+
t.equal(res.statusCode, 200)
103+
t.ok(/<html>.*Index of \/test\/fixtures<[\s\S]+index\.html[\s\S]+space in filename\.txt[\s\S]+<\/html>/.test(body.toString()))
104+
t.end()
105+
})
106+
})
107+
100108
test('space in filename', (t) => {
101109
req('/test/test/fixtures/space in filename.txt', (er, res, body) => {
102110
t.equal(res.statusCode, 200)

0 commit comments

Comments
 (0)