import {PathLike, UniversalPath} from './path' import {HTTPFilesystem} from './path/HTTPFilesystem' import {make} from '../../make' import {Filesystem} from './path/Filesystem' import {Maybe} from './types' /** * Create a new UniversalPath from the given path-like segments. * @param parts */ export function universalPath(...parts: PathLike[]): UniversalPath { let [main, ...concats] = parts // eslint-disable-line prefer-const if ( !(main instanceof UniversalPath) ) { let fs: Maybe = undefined if ( main.toLowerCase().startsWith('https://') || main.toLowerCase().startsWith('http://') ) { fs = make(HTTPFilesystem) } main = new UniversalPath(main, fs) } return main.concat(...concats) }