Skip to content

Commit

Permalink
Fix path normalization to support UNC paths
Browse files Browse the repository at this point in the history
  • Loading branch information
mikiher committed Aug 7, 2024
1 parent 2c8ebd4 commit d72e0a4
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions server/utils/fileUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const { AudioMimeType } = require('./constants')
*/
const filePathToPOSIX = (path) => {
if (!global.isWin || !path) return path
return path.replace(/\\/g, '/')
return path.startsWith('\\\\') ? '\\\\' + path.slice(2).replace(/\\/g, '/') : path.replace(/\\/g, '/')
}
module.exports.filePathToPOSIX = filePathToPOSIX

Expand Down Expand Up @@ -169,7 +169,7 @@ async function recurseFiles(path, relPathToReplace = null) {
extensions: true,
deep: true,
realPath: true,
normalizePath: true
normalizePath: false
}
let list = await rra.list(path, options)
if (list.error) {
Expand All @@ -186,6 +186,8 @@ async function recurseFiles(path, relPathToReplace = null) {
return false
}

item.fullname = filePathToPOSIX(item.fullname)
item.path = filePathToPOSIX(item.path)
const relpath = item.fullname.replace(relPathToReplace, '')
let reldirname = Path.dirname(relpath)
if (reldirname === '.') reldirname = ''
Expand Down

0 comments on commit d72e0a4

Please sign in to comment.