UNPKG

vue-files-preview-inno

Version:

A tool for previewing files such as doc, excel, pdf, image, markdown, txt, audio, and video and so on.

66 lines (65 loc) 1.59 kB
import t from "../../../path-webpack/path.mjs"; class l { constructor(e) { var r, s; r = e.indexOf("://"), r > -1 && (e = new URL(e).pathname), s = this.parse(e), this.path = e, this.isDirectory(e) ? this.directory = e : this.directory = s.dir + "/", this.filename = s.base, this.extension = s.ext.slice(1); } /** * Parse the path: https://nodejs.org/api/path.html#path_path_parse_path * @param {string} what * @returns {object} */ parse(e) { return t.parse(e); } /** * @param {string} what * @returns {boolean} */ isAbsolute(e) { return t.isAbsolute(e || this.path); } /** * Check if path ends with a directory * @param {string} what * @returns {boolean} */ isDirectory(e) { return e.charAt(e.length - 1) === "/"; } /** * Resolve a path against the directory of the Path * * https://nodejs.org/api/path.html#path_path_resolve_paths * @param {string} what * @returns {string} resolved */ resolve(e) { return t.resolve(this.directory, e); } /** * Resolve a path relative to the directory of the Path * * https://nodejs.org/api/path.html#path_path_relative_from_to * @param {string} what * @returns {string} relative */ relative(e) { var r = e && e.indexOf("://") > -1; return r ? e : t.relative(this.directory, e); } splitPath(e) { return this.splitPathRe.exec(e).slice(1); } /** * Return the path string * @returns {string} path */ toString() { return this.path; } } export { l as default }; //# sourceMappingURL=path.mjs.map