All files / app/common/utility joinPaths.ts

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13    318x 78x 78x   78x   6x   162x    
/* eslint-disable import/export */
export default function joinPaths(first: string, second: string, ...paths: string[]): string;
export default function joinPaths(...paths: string[]): string {
    const first = paths.shift() || '';
    const last = paths.pop() || '';
 
    return [
        first.replace(/\/$/, ''),
        ...paths.map(path => path.replace(/^\/|\/$/g, '')),
        last.replace(/^\//, ''),
    ].filter(value => !!value).join('/');
}