path.js (564B)
1 /* This Source Code Form is subject to the terms of the Mozilla Public 2 * License, v. 2.0. If a copy of the MPL was not distributed with this 3 * file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */ 4 5 export function basename(path) { 6 return path.split("/").pop(); 7 } 8 9 export function dirname(path) { 10 const idx = path.lastIndexOf("/"); 11 return path.slice(0, idx); 12 } 13 14 export function isURL(str) { 15 return str.includes("://"); 16 } 17 18 export function isAbsolute(str) { 19 return str[0] === "/"; 20 } 21 22 export function join(base, dir) { 23 return `${base}/${dir}`; 24 }