UNPKG

@flex-development/pathe

Version:

Universal drop-in replacement for node:path

20 lines (19 loc) 621 B
import validateString from "#internal/validate-string"; import validateURLString from "#internal/validate-url-string"; import formatExt from "#lib/format-ext"; var remove_ext_default = removeExt; function removeExt(input, ext) { validateURLString(input, "input"); if (typeof input === "string") { if (ext !== null && ext !== void 0) { validateString(ext, "ext"); ext = formatExt(ext); } if (!ext || !input.endsWith(ext)) return input; return input.slice(0, input.lastIndexOf(ext)); } return input.href = removeExt(input.href, ext), input; } export { remove_ext_default as default };