fix(parse): fix tests and many issues (#9)

This commit is contained in:
Fabrice Marsaud 2016-06-06 17:56:59 +02:00 committed by Julien Fontanet
parent c639cfcfd9
commit 509e99913a
2 changed files with 8 additions and 8 deletions

View File

@ -10,7 +10,7 @@ export const parse = url => {
url = url.url url = url.url
} }
const remote = {} const remote = {url}
const [type, rest] = url.split('://') const [type, rest] = url.split('://')
if (type === 'file') { if (type === 'file') {
@ -24,12 +24,12 @@ export const parse = url => {
remote.share = share remote.share = share
} else if (type === 'smb') { } else if (type === 'smb') {
remote.type = 'smb' remote.type = 'smb'
const lastArobas = rest.lastIndexOf('@') const lastAtSign = rest.lastIndexOf('@')
const smb = rest.slice(lastArobas) const smb = rest.slice(lastAtSign + 1)
const auth = rest.slice(0, lastArobas) const auth = rest.slice(0, lastAtSign)
const firstColon = auth.indexOf(':') const firstColon = auth.indexOf(':')
const username = auth.slice(0, firstColon) const username = auth.slice(0, firstColon)
const password = auth.slice(firstColon) const password = auth.slice(firstColon + 1)
const [domain, sh] = smb.split('\\\\') const [domain, sh] = smb.split('\\\\')
const [host, path] = sh.split('\0') const [host, path] = sh.split('\0')
remote.host = host remote.host = host

View File

@ -19,7 +19,7 @@ const data = {
url: 'smb://Administrator:password@toto\\\\192.168.100.225\\smb\0', url: 'smb://Administrator:password@toto\\\\192.168.100.225\\smb\0',
type: 'smb', type: 'smb',
host: '192.168.100.225\\smb', host: '192.168.100.225\\smb',
path: undefined, path: '',
domain: 'toto', domain: 'toto',
username: 'Administrator', username: 'Administrator',
password: 'password' password: 'password'
@ -28,7 +28,7 @@ const data = {
url: 'smb://Administrator:pass@word@toto\\\\192.168.100.225\\smb\0', url: 'smb://Administrator:pass@word@toto\\\\192.168.100.225\\smb\0',
type: 'smb', type: 'smb',
host: '192.168.100.225\\smb', host: '192.168.100.225\\smb',
path: undefined, path: '',
domain: 'toto', domain: 'toto',
username: 'Administrator', username: 'Administrator',
password: 'pass@word' password: 'pass@word'
@ -37,7 +37,7 @@ const data = {
url: 'smb://Administrator:pass:word@toto\\\\192.168.100.225\\smb\0', url: 'smb://Administrator:pass:word@toto\\\\192.168.100.225\\smb\0',
type: 'smb', type: 'smb',
host: '192.168.100.225\\smb', host: '192.168.100.225\\smb',
path: undefined, path: '',
domain: 'toto', domain: 'toto',
username: 'Administrator', username: 'Administrator',
password: 'pass:word' password: 'pass:word'