Skip to content

Commit e5a883d

Browse files
committed
fix: improve bundled fs files detection (allow whitespace)
1 parent a9613a6 commit e5a883d

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

bundler/bundle.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -189,15 +189,15 @@ export const build = async (...files) => {
189189
}
190190

191191
specificLoadPipeline.push(async (source, filepath) => {
192-
for (const match of source.matchAll(/readFileSync\((?:"([^"\\]+)"|'([^'\\]+)')[),]/gu)) {
193-
await fsFilesAdd(match[1] || match[2])
192+
for (const m of source.matchAll(/readFileSync\(\s*(?:"([^"\\]+)"|'([^'\\]+)')[),]/gu)) {
193+
await fsFilesAdd(m[1] || m[2])
194194
}
195195

196196
// E.g. path.join(import.meta.dirname, './fixtures/data.json'), dirname is inlined by loadPipeline already
197197
const dir = dirname(filepath)
198-
for (const match of source.matchAll(/join\(("[^"\\]+"), (?:"([^"\\]+)"|'([^'\\]+)')\)/gu)) {
199-
if (match[1] !== JSON.stringify(dir)) continue // only allow files relative to dirname, from loadPipeline
200-
const file = relative(cwd, join(dir, match[2] || match[3]))
198+
for (const m of source.matchAll(/join\(\s*("[^"\\]+"),\s*(?:"([^"\\]+)"|'([^'\\]+)')\s*\)/gu)) {
199+
if (m[1] !== JSON.stringify(dir)) continue // only allow files relative to dirname, from loadPipeline
200+
const file = relative(cwd, join(dir, m[2] || m[3]))
201201
if (/\.(json|txt)$/u.test(file)) await fsFilesAdd(file) // only allow json/txt files
202202
}
203203

0 commit comments

Comments
 (0)