UNPKG

@woosh/meep-engine

Version:

Pure JavaScript game engine. Fully featured and production ready.

24 lines (21 loc) 555 B
import { computePathBase } from "./computePathBase.js"; /** * Get name of a file from a given path * @param {string} path * @returns {string} * * @example * 'a/b/c.txt' -> 'c' * 'hello.txt' -> 'hello' * 'http://meep.com/index.html' -> 'index' */ export function computeFileName(path) { const base = computePathBase(path); const lastDotIndex = base.lastIndexOf('.'); if (lastDotIndex !== -1) { return base.substring(0, lastDotIndex); } else { //no extension return base; } }