diff --git a/packages/xo-remote-parser/src/index.js b/packages/xo-remote-parser/src/index.js index ea1f21c1f..7bbc3a52e 100644 --- a/packages/xo-remote-parser/src/index.js +++ b/packages/xo-remote-parser/src/index.js @@ -10,7 +10,7 @@ export const parse = url => { url = url.url } - const remote = {} + const remote = {url} const [type, rest] = url.split('://') if (type === 'file') { @@ -24,12 +24,12 @@ export const parse = url => { remote.share = share } else if (type === 'smb') { remote.type = 'smb' - const lastArobas = rest.lastIndexOf('@') - const smb = rest.slice(lastArobas) - const auth = rest.slice(0, lastArobas) + const lastAtSign = rest.lastIndexOf('@') + const smb = rest.slice(lastAtSign + 1) + const auth = rest.slice(0, lastAtSign) const firstColon = auth.indexOf(':') const username = auth.slice(0, firstColon) - const password = auth.slice(firstColon) + const password = auth.slice(firstColon + 1) const [domain, sh] = smb.split('\\\\') const [host, path] = sh.split('\0') remote.host = host diff --git a/packages/xo-remote-parser/src/index.spec.js b/packages/xo-remote-parser/src/index.spec.js index c396be6cf..7ca45d0dd 100644 --- a/packages/xo-remote-parser/src/index.spec.js +++ b/packages/xo-remote-parser/src/index.spec.js @@ -19,7 +19,7 @@ const data = { url: 'smb://Administrator:password@toto\\\\192.168.100.225\\smb\0', type: 'smb', host: '192.168.100.225\\smb', - path: undefined, + path: '', domain: 'toto', username: 'Administrator', password: 'password' @@ -28,7 +28,7 @@ const data = { url: 'smb://Administrator:pass@word@toto\\\\192.168.100.225\\smb\0', type: 'smb', host: '192.168.100.225\\smb', - path: undefined, + path: '', domain: 'toto', username: 'Administrator', password: 'pass@word' @@ -37,7 +37,7 @@ const data = { url: 'smb://Administrator:pass:word@toto\\\\192.168.100.225\\smb\0', type: 'smb', host: '192.168.100.225\\smb', - path: undefined, + path: '', domain: 'toto', username: 'Administrator', password: 'pass:word'