You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
22 lines
767 B
22 lines
767 B
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<Filesystem> = undefined
|
|
if ( main.toLowerCase().startsWith('https://') || main.toLowerCase().startsWith('http://') ) {
|
|
fs = make(HTTPFilesystem)
|
|
}
|
|
main = new UniversalPath(main, fs)
|
|
}
|
|
return main.concat(...concats)
|
|
}
|