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.

48 lines (47 loc) 1.59 kB
import r from "./path.mjs"; import a from "../../../path-webpack/path.mjs"; class c { constructor(t, i) { var s = t.indexOf("://") > -1, h = t, e; if (this.Url = void 0, this.href = t, this.protocol = "", this.origin = "", this.hash = "", this.hash = "", this.search = "", this.base = i, !s && i !== !1 && typeof i != "string" && window && window.location && (this.base = window.location.href), s || this.base) try { this.base ? this.Url = new URL(t, this.base) : this.Url = new URL(t), this.href = this.Url.href, this.protocol = this.Url.protocol, this.origin = this.Url.origin, this.hash = this.Url.hash, this.search = this.Url.search, h = this.Url.pathname + (this.Url.search ? this.Url.search : ""); } catch { this.Url = void 0, this.base && (e = new r(this.base), h = e.resolve(h)); } this.Path = new r(h), this.directory = this.Path.directory, this.filename = this.Path.filename, this.extension = this.Path.extension; } /** * @returns {Path} */ path() { return this.Path; } /** * Resolves a relative path to a absolute url * @param {string} what * @returns {string} url */ resolve(t) { var i = t.indexOf("://") > -1, s; return i ? t : (s = a.resolve(this.directory, t), this.origin + s); } /** * Resolve a path relative to the url * @param {string} what * @returns {string} path */ relative(t) { return a.relative(t, this.directory); } /** * @returns {string} */ toString() { return this.href; } } export { c as default }; //# sourceMappingURL=url.mjs.map