Javascript PathJoin

Date: 2018-12-13
const pathJoin = (...args: any[]): string => {
    const r = Array.from(args)
        .map(s => String(s))
        .map((s, i, a) => {
            if (i !== 0 && s.charAt(0) === "/") { return s.substr(1); }
            if (i !== a.length - 1 && s.charAt(s.length - 1) === "/") { return s.slice(0, -1); }
            return s;
        });
    return r.join("/");
};
16830cookie-checkJavascript PathJoin