param pathString export function cleanPath ( pathString ) { return pathString . replace ( /^\.\./ , '' ) . replace ( /^\./ , '' ) . replace ( /^\// , '' ) . replace ( /\/$/ , '' ) ; } param source { String } param target { String } return export function getRelativePath ( source , target ) { const sep = '/' ; const targetArr = target . split ( sep ) ; const sourceArr = source . split ( sep ) ; const filename = targetArr . pop ( ) ; const targetPath = targetArr . join ( sep ) ; let relativePath = '' ; while ( targetPath . indexOf ( sourceArr . join ( sep ) ) === - 1 ) { sourceArr . pop ( ) ; relativePath += '..' + sep ; } const relPathArr = targetArr . slice ( sourceArr . length ) ; if ( relPathArr . length ) { relativePath += relPathArr . join ( sep ) + sep ; } return relativePath + filename ; } export function findNextIndexedKeyInObject ( object , key ) { if ( ! object [ key ] ) return key ; let i = 1 ; while ( object [ key + '_' + i ] !== undefined ) { i ++ ; } return key + '_' + i ; }