fix(parse): do not edit the remote object inplace

This commit is contained in:
Julien Fontanet 2016-06-06 17:17:57 +02:00
parent b140a2ca3e
commit c639cfcfd9

View File

@ -5,8 +5,14 @@ import trimStart from 'lodash/trimStart'
const sanitizePath = (...paths) => filter(map(paths, s => s && filter(map(s.split('/'), trim)).join('/'))).join('/')
export const parse = (remote) => {
const [type, rest] = remote.url.split('://')
export const parse = url => {
if (typeof url === 'object') {
url = url.url
}
const remote = {}
const [type, rest] = url.split('://')
if (type === 'file') {
remote.type = 'local'
remote.path = `/${trimStart(rest, '/')}` // the leading slash has been forgotten on client side first implementation