mirror of
https://github.com/orbitdb/orbitdb.git
synced 2025-10-07 22:57:07 +00:00
Change default join to posix.
This commit is contained in:
@@ -1,13 +1,12 @@
|
||||
const posixReg = /((?<=\/)\/+)|(^\.\/)|((?<=\/)\.\/)/g
|
||||
const win32Reg = /((?<=\\)\\+)|(^\.\\)|((?<=\\)\.\\)/g
|
||||
export const posixJoin = (...paths) => paths
|
||||
.join('/')
|
||||
.replace(/((?<=\/)\/+)|(^\.\/)|((?<=\/)\.\/)/g, '') || '.'
|
||||
|
||||
const createJoin = isWin => (...paths) => isWin ?
|
||||
paths.join('\\').replace(/\//g, '\\').replace(win32Reg, '') :
|
||||
paths.join('/').replace(posixReg, '')
|
||||
export const win32Join = (...paths) => paths
|
||||
.join('\\')
|
||||
.replace(/\//g, '\\')
|
||||
.replace(/((?<=\\)\\+)|(^\.\\)|((?<=\\)\.\\)/g, '') || '.'
|
||||
|
||||
export const join = createJoin(typeof process !== 'undefined' && process?.platform === 'win32')
|
||||
export const join = posixJoin
|
||||
|
||||
export const posixJoin = createJoin(false)
|
||||
export const win32Join = createJoin(true)
|
||||
|
||||
export default join
|
||||
export default posixJoin
|
||||
|
||||
Reference in New Issue
Block a user