Handling a missing leading slash in nfs path
This commit is contained in:
parent
45ec0b9b01
commit
6cced719dc
@ -16,7 +16,7 @@ export const parse = string => {
|
||||
object.type = 'nfs'
|
||||
const [host, path] = rest.split(':')
|
||||
object.host = host
|
||||
object.path = path
|
||||
object.path = `/${trimStart(path, '/')}` // takes care of a missing leading slash coming from previous version format
|
||||
} else if (type === 'smb') {
|
||||
object.type = 'smb'
|
||||
const lastAtSign = rest.lastIndexOf('@')
|
||||
@ -50,7 +50,7 @@ export const format = ({type, host, path, username, password, domain}) => {
|
||||
path = path.split('/')
|
||||
path = '\0' + path.join('\\') // FIXME saving with the windows fashion \ was a bad idea :,(
|
||||
} else {
|
||||
type === 'file' && (path = `/${path}`)
|
||||
path = `/${path}`
|
||||
}
|
||||
string += path
|
||||
return string
|
||||
|
@ -30,11 +30,11 @@ const data = deepFreeze({
|
||||
}
|
||||
},
|
||||
NFS: {
|
||||
string: 'nfs://192.168.100.225:media/nfs',
|
||||
string: 'nfs://192.168.100.225:/media/nfs',
|
||||
object: {
|
||||
type: 'nfs',
|
||||
host: '192.168.100.225',
|
||||
path: 'media/nfs'
|
||||
path: '/media/nfs'
|
||||
}
|
||||
}
|
||||
})
|
||||
@ -48,6 +48,14 @@ const parseData = deepFreeze({
|
||||
type: 'file',
|
||||
path: '/var/lib/xoa/backup'
|
||||
}
|
||||
},
|
||||
'nfs with missing leading slash': {
|
||||
string: 'nfs://192.168.100.225:media/nfs',
|
||||
object: {
|
||||
type: 'nfs',
|
||||
host: '192.168.100.225',
|
||||
path: '/media/nfs'
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user