Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fix path normalization #22

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 10 additions & 8 deletions src/util.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
const path = require('path')
const normalize_path = function (p) {
p = path.normalize(p);
p = path.resolve(process.cwd(), p)
// p = path.relative(require.main.path, p)
p = p.replace(new RegExp(`^${path.sep}+`, 'g'), '');
// p = `${p}`
// p = `s3fs:${p}`
return p
p = p.split('\\').join('/')

let targetPath = p
if (targetPath[0] === '/') targetPath = targetPath.substr(1, targetPath.length - 1)

let lastChar = targetPath[targetPath.length - 1]
if (lastChar !== '/') targetPath += '/'

return targetPath
}

const normalize_dir = function(p){
Expand All @@ -19,4 +21,4 @@ const normalize_dir = function(p){
module.exports = {
normalize_path,
normalize_dir
}
}