Skip to content

Commit

Permalink
fix: fix bug in filesystem.insertLink
Browse files Browse the repository at this point in the history
  • Loading branch information
jrainliu committed Jan 31, 2024
1 parent 79af07d commit 4f57777
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@
.node-version
npm-debug.log
.idea
.vscode
4 changes: 3 additions & 1 deletion lib/filesystem.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,9 @@ class Filesystem {
}

insertLink (p) {
const link = path.relative(fs.realpathSync(this.src), fs.realpathSync(p))
const symlink = fs.readlinkSync(p)
const parentPath = path.dirname(p)
const link = path.relative(fs.realpathSync(this.src), path.join(parentPath, symlink))
if (link.substr(0, 2) === '..') {
throw new Error(`${p}: file "${link}" links out of the package`)
}
Expand Down

0 comments on commit 4f57777

Please sign in to comment.