@zthun/webigail-url 2.1.1 → 2.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +27 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +27 -1
- package/dist/index.js.map +1 -1
- package/dist/url/url.d.mts +2 -0
- package/package.json +4 -3
package/dist/index.cjs
CHANGED
|
@@ -523,7 +523,33 @@ const _ZUrlBuilder = class _ZUrlBuilder {
|
|
|
523
523
|
* This object.
|
|
524
524
|
*/
|
|
525
525
|
search(search) {
|
|
526
|
-
return this.onlyParam("search", search
|
|
526
|
+
return this.onlyParam("search", search || void 0);
|
|
527
|
+
}
|
|
528
|
+
/**
|
|
529
|
+
* Adds a filter param.
|
|
530
|
+
*
|
|
531
|
+
* @param filter -
|
|
532
|
+
* The filter param to add. If this is null, undefined,
|
|
533
|
+
* or empty, then any filter param is deleted.
|
|
534
|
+
*
|
|
535
|
+
* @returns
|
|
536
|
+
* This object.
|
|
537
|
+
*/
|
|
538
|
+
filter(filter) {
|
|
539
|
+
return this.onlyParam("filter", filter || void 0);
|
|
540
|
+
}
|
|
541
|
+
/**
|
|
542
|
+
* Adds a sort param.
|
|
543
|
+
*
|
|
544
|
+
* @param sort -
|
|
545
|
+
* The sort param to add. If this is null, undefined,
|
|
546
|
+
* or empty, then any filter param is deleted.
|
|
547
|
+
*
|
|
548
|
+
* @returns
|
|
549
|
+
* This object.
|
|
550
|
+
*/
|
|
551
|
+
sort(sort) {
|
|
552
|
+
return this.onlyParam("sort", sort || void 0);
|
|
527
553
|
}
|
|
528
554
|
/**
|
|
529
555
|
* Builds the url string and returns it.
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":["../src/mime/mime-type-application.mts","../src/mime/mime-type-image.mts","../src/mime/mime-type-text.mts","../src/mime/mime-type.mts","../src/data/data-url.mts","../src/url/url.mts"],"sourcesContent":["/* cspell:disable */\n\n/**\n * Application mime types.\n */\nexport enum ZMimeTypeApplication {\n /**\n * JSON data.\n */\n JSON = 'application/json',\n\n /**\n * The unknown type.\n *\n * Used for raw byte data.\n */\n OctetStream = 'application/octet-stream',\n\n /**\n * Compressed zip stream.\n */\n Zip = 'application/zip'\n}\n","/* cspell:disable */\n\n/**\n * Mime types for images.\n */\nexport enum ZMimeTypeImage {\n /**\n * Good choice for lossless animation sequences (GIF is less performant). AVIF and\n * WebP have better performance but less broad browser support.\n */\n APNG = 'image/apng',\n\n /**\n * Good choice for both images and animated images due to high performance and\n * royalty free image format. It offers much better compression than PNG or JPEG\n * with support for higher color depths, animated frames, transparency etc.\n *\n * Note that when using AVIF, you should include fallbacks to formats with\n * better browser support (i.e. using the <picture> element).\n */\n AVIF = 'image/avif',\n\n /**\n * Good choice for simple images and animations. Prefer PNG for lossless and\n * indexed still images, and consider WebP, AVIF or APNG for animation sequences.\n */\n GIF = 'image/gif',\n\n /**\n * Good choice for lossy compression of still images (currently the most popular). Prefer\n * PNG when more precise reproduction of the image is required, or WebP/AVIF if both better\n * reproduction and higher compression are required.\n */\n JPEG = 'image/jpeg',\n\n /**\n * PNG is preferred over JPEG for more precise reproduction of source images, or when\n * transparency is needed. WebP/AVIF provide even better compression and reproduction,\n * but browser support is more limited.\n */\n PNG = 'image/png',\n\n /**\n * Vector image format; ideal for user interface elements, icons, diagrams, etc., that\n * must be drawn accurately at different sizes.\n */\n SVG = 'image/svg+xml',\n\n /**\n * Excellent choice for both images and animated images. WebP offers much better compression\n * than PNG or JPEG with support for higher color depths, animated frames, transparency etc.\n * AVIF offers slightly better compression, but is not quite as well-supported in browsers\n * and does not support progressive rendering.\n */\n WebP = 'image/webp'\n}\n","/* cspell:disable */\n\n/**\n * Mime types for text based data.\n */\nexport enum ZMimeTypeText {\n /**\n * Style files used in html documents must be sent as\n * css.\n */\n CSS = 'text/css',\n\n /**\n * Comma separated values.\n */\n CSV = 'text/csv',\n\n /**\n * JavaScript.\n */\n EcmaScript = 'text/ecmascript',\n\n /**\n * Hyper Text Markup Language. Markup language for\n * web pages.\n */\n HTML = 'text/html',\n\n /**\n * JavaScript.\n */\n JavaScript = 'text/javascript',\n\n /**\n * Plain (basic) text.\n */\n Plain = 'text/plain',\n\n /**\n * Xtreme Markup Language.\n *\n * Superset of HTML. Bulky, but can\n * represent anything.\n */\n XML = 'text/xml'\n}\n","import { keyBy } from 'lodash-es';\nimport { ZMimeTypeApplication } from './mime-type-application.mjs';\nimport { ZMimeTypeImage } from './mime-type-image.mjs';\nimport { ZMimeTypeText } from './mime-type-text.mjs';\n\n/**\n * Mime types for file data.\n */\nexport type ZMimeType = ZMimeTypeApplication | ZMimeTypeText | ZMimeTypeImage;\n\n/**\n * A mapping of supported mime types.\n */\nexport const ZSupportedMimeTypes = Object.freeze({\n ...{ '': 'text/plain;charset=ASCII' },\n ...keyBy(Object.values(ZMimeTypeApplication)),\n ...keyBy(Object.values(ZMimeTypeText)),\n ...keyBy(Object.values(ZMimeTypeImage))\n});\n","import { Buffer } from 'buffer';\nimport { last } from 'lodash-es';\nimport { ZMimeTypeApplication } from '../mime/mime-type-application.mjs';\nimport { ZSupportedMimeTypes } from '../mime/mime-type.mjs';\n\n/**\n * Represents information about a data url.\n */\nexport interface IZDataUrlInfo {\n /**\n * The content information mime type.\n */\n mimeType: string;\n\n /**\n * The output encoding.\n */\n encoding: 'base64' | 'utf8';\n\n /**\n * The raw data buffer.\n */\n buffer: Buffer;\n}\n\n/**\n * Represents an object that is helpful in building a data url with support\n * for data encoding.\n */\nexport class ZDataUrlBuilder {\n /**\n * The representation of the data url object.\n */\n private _data: IZDataUrlInfo;\n\n /**\n * Initializes a new instance of this object.\n */\n public constructor() {\n this._data = {\n mimeType: '',\n encoding: 'utf8',\n buffer: Buffer.from('')\n };\n }\n\n /**\n * Parses an existing data url and sets all properties.\n *\n * @param url -\n * The url to parse.\n *\n * @returns\n * This object.\n */\n public parse(url: string): this {\n this._data = {\n mimeType: '',\n encoding: 'utf8',\n buffer: Buffer.from('')\n };\n\n if (!url.startsWith('data:')) {\n return this;\n }\n\n url = url.substring(5);\n const parts = url.split(',');\n\n if (parts.length < 2) {\n return this;\n }\n\n const [mimeType, ...bodyParts] = parts;\n let [type, ...params] = mimeType.split(';');\n\n const isBase64 = last(params) === 'base64';\n\n this._data.encoding = isBase64 ? 'base64' : 'utf8';\n\n if (isBase64) {\n params.pop();\n }\n\n if (!Object.hasOwnProperty.call(ZSupportedMimeTypes, type)) {\n type = ZMimeTypeApplication.OctetStream;\n params = [];\n }\n\n type = [type, ...params].join(';');\n\n this._data.mimeType = type;\n\n // Commas can be in the body. Type this into chrome and you can\n // see that chrome actually parses it: data:text/plain,cat,,,\n // We will support this here, but we're going to properly encode it.\n const body = bodyParts.join('%2C');\n this._data.buffer = isBase64 ? Buffer.from(body, 'base64') : Buffer.from(decodeURIComponent(body));\n return this;\n }\n\n /**\n * Sets the mime type.\n *\n * @param type -\n * The mime type.\n *\n * @returns\n * This object.\n */\n public mimeType(type: string): this {\n this._data.mimeType = type;\n return this;\n }\n\n /**\n * Sets the data buffer.\n *\n * @param data -\n * The data to set. If you pass a raw string, then the input encoding\n * is expected to be utf8.\n * @returns\n * This object.\n */\n public buffer(data: Buffer | string): this {\n this._data.buffer = typeof data === 'string' ? Buffer.from(data) : data;\n return this;\n }\n\n /**\n * Sets the output encoding.\n *\n * If you output encode the data as utf8, then it will be properly\n * escaped.\n *\n * @param encoding -\n * The output encoding.\n *\n * @returns\n * This object.\n */\n public encode(encoding: 'base64' | 'utf8'): this {\n this._data.encoding = encoding;\n return this;\n }\n\n /**\n * Builds the url string and returns it.\n *\n * @returns The url string.\n */\n public build(): string {\n const protocol = 'data';\n const modifier = this._data.encoding === 'base64' ? ';base64' : '';\n\n let raw = this._data.buffer.toString(this._data.encoding);\n\n if (this._data.encoding === 'utf8') {\n raw = encodeURIComponent(raw);\n\n // Note ! should be encoded as %21, but for uri's..it's not because\n // it's actually valid, but some servers don't accept ! as a character\n // and it must be encoded. Just fix it here.\n raw = raw.split('!').join('%21');\n }\n\n return `${protocol}:${this._data.mimeType}${modifier},${raw}`;\n }\n\n /**\n * Gets the current information about the url being built.\n *\n * @returns The current information about the url being built.\n */\n public info(): IZDataUrlInfo {\n const other = { ...this._data };\n other.buffer = this._data.buffer.slice();\n return other;\n }\n}\n","import { trim, trimEnd, trimStart } from 'lodash-es';\nimport URLParse from 'url-parse';\n\n/**\n * Represents information about a url.\n */\nexport interface IZUrlInfo {\n /**\n * The protocol for the url.\n */\n protocol: string;\n\n /**\n * The username.\n */\n username?: string;\n\n /**\n * The password.\n */\n password?: string;\n\n /**\n * The host.\n */\n hostname: string;\n\n /**\n * The port number.\n */\n port?: number;\n\n /**\n * A list of current paths.\n *\n * You can always get the full path using\n * path.join('/')\n */\n path: string[];\n\n /**\n * The client side hash route.\n */\n hash?: string;\n\n /**\n * The key value params.\n */\n params: Array<{ key: string; val: string }>;\n}\n\n/**\n * The api to target for YouTube.\n */\nexport enum ZYouTubeApi {\n /**\n * An embedded video link.\n */\n Embed = 'embed',\n /**\n * A watch video link.\n */\n Watch = 'watch'\n}\n\n/**\n * Represents an object that is helpful in building a url.\n */\nexport class ZUrlBuilder {\n /**\n * The url to the gravatar api.\n */\n public static UrlGravatar = 'https://s.gravatar.com/avatar';\n\n /**\n * The url to youtube.\n *\n * This is mostly used to embed videos.\n */\n public static UrlYouTube = 'https://www.youtube.com';\n\n /**\n * A mapping between protocol and default port.\n */\n public static ProtocolPorts = {\n http: 80,\n https: 443,\n ftp: 21,\n sftp: 22,\n ssh: 22,\n smtp: 25,\n smb: 445\n };\n\n /**\n * Gets whether the given protocols default port is port.\n *\n * The main purpose of this method is to determine if a url requires\n * a port section. Therefore, there are some special behaviors which may\n * not be obvious:\n *\n * 1. If the port is falsy then this method returns true.\n * 2. If the port is NaN, then this method returns true.\n * 3. If the port is a string that evaluates to 0, then this method returns true.\n * 4. If port is less than 0, then this method returns true.\n *\n * @param protocol -\n * The protocol to check.\n * @param port -\n * The port to compare.\n *\n * @returns\n * True if the default port for protocol is port.\n */\n public static defaults(protocol: string, port: string | number): boolean {\n const numericPort = +port;\n\n if (isNaN(numericPort) || numericPort < 1) {\n return true;\n }\n\n return ZUrlBuilder.ProtocolPorts[protocol] === +port;\n }\n\n /**\n * The representation of the url object.\n */\n private readonly _url: IZUrlInfo;\n\n /**\n * Initializes a new instance of this object.\n *\n * @param protocol -\n * The protocol to use.\n * @param hostname -\n * The hostname to connect with.\n */\n public constructor(protocol = 'http', hostname = 'localhost') {\n this._url = {\n protocol,\n hostname,\n path: ['/'],\n hash: '',\n params: []\n };\n }\n\n /**\n * Fills the information from the current location data.\n *\n * @param loc -\n * The optional location object to populate with.\n *\n * @returns\n * This object.\n */\n public location(loc: Location): this {\n this.protocol(loc.protocol).hostname(loc.hostname).hash(loc.hash).path(loc.pathname).port(+loc.port);\n\n let search = loc.search;\n\n if (search.startsWith('?')) {\n search = search.slice(1);\n const pairs = search.split('&');\n pairs.map((pair) => pair.split('=')).forEach((matrix) => this.param(matrix[0], matrix[1]));\n }\n\n return this;\n }\n\n /**\n * Fills the information for an api path call.\n *\n * This is a combination of location, hash with an empty string, and an\n * append of the basePath.\n *\n * @param loc -\n * The optional location object to populate with.\n * @param basePath -\n * The basePath for the api. Generally, it's best to\n * just keep this as api and have your server accept\n * this path.\n *\n * @returns\n * This object.\n */\n public api(loc: Location, basePath = 'api'): this {\n return this.location(loc).hash('').path(basePath);\n }\n\n /**\n * Parses an existing url and sets all properties.\n *\n * If you give this a path without the protocol and hostname, then it will\n * automatically append the protocol and host of the browser window if it\n * exists.\n *\n * This method sets all the properties so if you need to modify the url before\n * parsing it, it is best to always call this method first.\n *\n * @param url -\n * The url to parse.\n *\n * @returns\n * This object.\n */\n public parse(url: string) {\n const current = new URLParse(url, true);\n\n this.protocol(current.protocol)\n .username(current.username)\n .password(current.password)\n .hostname(current.hostname)\n .hash(current.hash)\n .path(current.pathname)\n .port(current.port ? +current.port : undefined);\n\n Object.keys(current.query).forEach((key) => this.param(key, current.query[key] as string));\n\n return this;\n }\n\n /**\n * Sets the url for a user gravatar.\n *\n * @param hash -\n * The md5 email hash.\n * @param size -\n * The dimensional size of the gravatar image.\n *\n * @returns\n * This object.\n */\n public gravatar(hash?: string, size?: number): this {\n let current = this.parse(ZUrlBuilder.UrlGravatar);\n current = hash ? current.append(hash) : current;\n current = size ? current.param('s', String(size)) : current;\n return current;\n }\n\n /**\n * Sets the url for a target video on YouTube.\n *\n * @param api -\n * The target api. If this is watch, then\n * it will be a target link to a youTube url.\n * If this is embed, then it will be a target\n * link that can be put into an iframe for\n * embedded youtube videos.\n * @param id -\n * The id of the video to watch.\n *\n * @returns\n * This object.\n */\n public youTube(api: ZYouTubeApi, id: string): this;\n\n /**\n * Sets the url to the base YouTube domain.\n *\n * @returns\n * This object.\n */\n public youTube(): this;\n\n /**\n * Sets the url target to something on YouTube.\n *\n * @param api -\n * The supported api.\n * @param id -\n * The id of the video. If api is set,\n * then this parameter is required.\n *\n * @returns\n * The url for YouTube. If you set the api and\n * id, then the url will be targeted to a specific video,\n * otherwise, the base domain url of YouTube will be returned.\n */\n public youTube(api?: ZYouTubeApi, id?: string) {\n let current = this.parse(ZUrlBuilder.UrlYouTube);\n current = api ? current.path(`${api}/${id}`) : current;\n\n // The watch api is a little bizarre that they don't actually\n // use the same format as their other apis. So we will handle this here.\n if (api === ZYouTubeApi.Watch) {\n current = current.path(api).param('v', id!);\n }\n\n return current;\n }\n\n /**\n * Sets the protocol.\n *\n * @param protocol -\n * The protocol.\n *\n * @returns\n * This object.\n */\n public protocol(protocol: string): this {\n this._url.protocol = protocol;\n return this;\n }\n\n /**\n * Sets the user name.\n *\n * Used for things like ssh and ftp.\n *\n * @param user -\n * The username\n *\n * @returns\n * This object.\n */\n public username(user: string | undefined): this {\n this._url.username = user;\n return this;\n }\n\n /**\n * Sets the password.\n *\n * This is only valid if the username is set.\n *\n * @param pwd -\n * The user password.\n *\n * @returns\n * This object.\n */\n public password(pwd: string | undefined): this {\n this._url.password = pwd;\n return this;\n }\n\n /**\n * Sets the host name.\n *\n * This sets the entire hostname as the root domain. This\n * will blow away any subdomains added, so it's best to\n * call this method first.\n *\n * @param host -\n * The hostname.\n *\n * @returns\n * This object.\n */\n public hostname(host: string): this {\n this._url.hostname = host;\n return this;\n }\n\n /**\n * Adds a subdomain in front of the hostname.\n *\n * If a hostname was never set, then domain becomes the hostname.\n *\n * @param domain -\n * The domain to append.\n *\n * @returns\n * This object.\n */\n public subdomain(domain: string): this {\n this._url.hostname = this._url.hostname ? `${domain}.${this._url.hostname}` : domain;\n return this;\n }\n\n /**\n * Removes a subdomain from the current domain.\n *\n * @returns\n * This object.\n */\n public popSubdomain(): this {\n const parts = this._url.hostname.split('.');\n parts.splice(0, 1);\n this._url.hostname = parts.join('.');\n return this;\n }\n\n /**\n * Sets the port.\n *\n * @param port -\n * The port.\n *\n * @returns\n * This object.\n */\n public port(port: number | undefined): this {\n this._url.port = port;\n return this;\n }\n\n /**\n * Removes all existing path segments and restarts the path.\n *\n * @param path -\n * The starting path.\n *\n * @returns\n * This object.\n */\n public path(path: string): this {\n this._url.path = [path];\n return this;\n }\n\n /**\n * Appends a path segment.\n *\n * @param path -\n * The segment to append.\n *\n * @returns\n * This object.\n */\n public append(path: string): this {\n this._url.path.push(path);\n return this;\n }\n\n /**\n * Sets the hash section.\n *\n * @param hash -\n * The hash section.\n *\n * @returns\n * This object.\n */\n public hash(hash: string | undefined): this {\n this._url.hash = hash;\n return this;\n }\n\n /**\n * Adds a search parameter.\n *\n * This version assumes that value is not null.\n *\n * @param key -\n * The parameter key.\n * @param val -\n * The parameter value.\n *\n * @returns\n * This object.\n */\n public param(key: string, val: string): this {\n this._url.params.push({ key, val });\n return this;\n }\n\n /**\n * Removes all duplicate params and adds one with the key to the value.\n *\n * @param key -\n * The parameter key that can have only one.\n * @param val -\n * The parameter value. If this is falsy, then\n * the key is deleted.\n */\n public onlyParam(key: string, val?: string): this {\n this._url.params = this._url.params.filter((p) => p.key !== key);\n return val ? this.param(key, val) : this;\n }\n\n /**\n * Adds a page param.\n *\n * @param page -\n * The page param to add. If this null, undefined,\n * or less than 1, then any page param is deleted.\n *\n * @returns\n * This object.\n */\n public page(page?: number | null): this {\n return this.onlyParam('page', page == null || page < 1 ? undefined : String(page));\n }\n\n /**\n * Adds a size param.\n *\n * @param size -\n * The size param to add. If this is null, undefined,\n * or less than 0, then any size param is deleted.\n *\n * @returns\n * This object.\n */\n public size(size?: number | null): this {\n return this.onlyParam('size', size == null || size < 0 ? undefined : String(size));\n }\n\n /**\n * Adds a search param.\n *\n * @param search -\n * The search param to add. If this is null, undefined,\n * or empty, then any search param is deleted.\n *\n * @returns\n * This object.\n */\n public search(search?: string | null): this {\n return this.onlyParam('search', search ? search : undefined);\n }\n\n /**\n * Builds the url string and returns it.\n *\n * @returns\n * The url string.\n */\n public build(): string {\n const search = this._url.params.map((param) => `${param.key}=${encodeURIComponent(param.val)}`).join('&');\n const user = trim(this._url.username);\n const password = trim(this._url.password);\n let protocol = trim(this._url.protocol);\n let host = trim(this._url.hostname);\n let port = String(this._url.port);\n let hash = trim(this._url.hash);\n let path = this._url.path.map((segment) => trim(segment, '/')).join('/');\n let credentials = '';\n\n protocol = trimEnd(protocol, '/:');\n host = trim(host, '/');\n hash = trimStart(hash, '#');\n path = trim(path, '/');\n\n if (ZUrlBuilder.defaults(protocol, port)) {\n port = '';\n } else {\n port = `:${port}`;\n }\n\n if (user) {\n credentials = password ? `${user}:${password}@` : `${user}@`;\n }\n\n let url = `${protocol}://${credentials}${host}${port}`;\n\n if (path) {\n url = `${url}/${path}`;\n }\n\n if (search) {\n url = `${url}/?${search}`;\n }\n\n if (hash) {\n url = `${url}#${hash}`;\n }\n\n return url;\n }\n\n /**\n * Gets the current information about the uri being built.\n *\n * @returns The current uri information.\n */\n public info(): IZUrlInfo {\n return JSON.parse(JSON.stringify(this._url));\n }\n}\n"],"names":["ZMimeTypeApplication","ZMimeTypeImage","ZMime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.mts","../src/mime/mime-type-text.mts","../src/mime/mime-type.mts","../src/data/data-url.mts","../src/url/url.mts"],"sourcesContent":["/* cspell:disable */\n\n/**\n * Application mime types.\n */\nexport enum ZMimeTypeApplication {\n /**\n * JSON data.\n */\n JSON = 'application/json',\n\n /**\n * The unknown type.\n *\n * Used for raw byte data.\n */\n OctetStream = 'application/octet-stream',\n\n /**\n * Compressed zip stream.\n */\n Zip = 'application/zip'\n}\n","/* cspell:disable */\n\n/**\n * Mime types for images.\n */\nexport enum ZMimeTypeImage {\n /**\n * Good choice for lossless animation sequences (GIF is less performant). AVIF and\n * WebP have better performance but less broad browser support.\n */\n APNG = 'image/apng',\n\n /**\n * Good choice for both images and animated images due to high performance and\n * royalty free image format. It offers much better compression than PNG or JPEG\n * with support for higher color depths, animated frames, transparency etc.\n *\n * Note that when using AVIF, you should include fallbacks to formats with\n * better browser support (i.e. using the <picture> element).\n */\n AVIF = 'image/avif',\n\n /**\n * Good choice for simple images and animations. Prefer PNG for lossless and\n * indexed still images, and consider WebP, AVIF or APNG for animation sequences.\n */\n GIF = 'image/gif',\n\n /**\n * Good choice for lossy compression of still images (currently the most popular). Prefer\n * PNG when more precise reproduction of the image is required, or WebP/AVIF if both better\n * reproduction and higher compression are required.\n */\n JPEG = 'image/jpeg',\n\n /**\n * PNG is preferred over JPEG for more precise reproduction of source images, or when\n * transparency is needed. WebP/AVIF provide even better compression and reproduction,\n * but browser support is more limited.\n */\n PNG = 'image/png',\n\n /**\n * Vector image format; ideal for user interface elements, icons, diagrams, etc., that\n * must be drawn accurately at different sizes.\n */\n SVG = 'image/svg+xml',\n\n /**\n * Excellent choice for both images and animated images. WebP offers much better compression\n * than PNG or JPEG with support for higher color depths, animated frames, transparency etc.\n * AVIF offers slightly better compression, but is not quite as well-supported in browsers\n * and does not support progressive rendering.\n */\n WebP = 'image/webp'\n}\n","/* cspell:disable */\n\n/**\n * Mime types for text based data.\n */\nexport enum ZMimeTypeText {\n /**\n * Style files used in html documents must be sent as\n * css.\n */\n CSS = 'text/css',\n\n /**\n * Comma separated values.\n */\n CSV = 'text/csv',\n\n /**\n * JavaScript.\n */\n EcmaScript = 'text/ecmascript',\n\n /**\n * Hyper Text Markup Language. Markup language for\n * web pages.\n */\n HTML = 'text/html',\n\n /**\n * JavaScript.\n */\n JavaScript = 'text/javascript',\n\n /**\n * Plain (basic) text.\n */\n Plain = 'text/plain',\n\n /**\n * Xtreme Markup Language.\n *\n * Superset of HTML. Bulky, but can\n * represent anything.\n */\n XML = 'text/xml'\n}\n","import { keyBy } from 'lodash-es';\nimport { ZMimeTypeApplication } from './mime-type-application.mjs';\nimport { ZMimeTypeImage } from './mime-type-image.mjs';\nimport { ZMimeTypeText } from './mime-type-text.mjs';\n\n/**\n * Mime types for file data.\n */\nexport type ZMimeType = ZMimeTypeApplication | ZMimeTypeText | ZMimeTypeImage;\n\n/**\n * A mapping of supported mime types.\n */\nexport const ZSupportedMimeTypes = Object.freeze({\n ...{ '': 'text/plain;charset=ASCII' },\n ...keyBy(Object.values(ZMimeTypeApplication)),\n ...keyBy(Object.values(ZMimeTypeText)),\n ...keyBy(Object.values(ZMimeTypeImage))\n});\n","import { Buffer } from 'buffer';\nimport { last } from 'lodash-es';\nimport { ZMimeTypeApplication } from '../mime/mime-type-application.mjs';\nimport { ZSupportedMimeTypes } from '../mime/mime-type.mjs';\n\n/**\n * Represents information about a data url.\n */\nexport interface IZDataUrlInfo {\n /**\n * The content information mime type.\n */\n mimeType: string;\n\n /**\n * The output encoding.\n */\n encoding: 'base64' | 'utf8';\n\n /**\n * The raw data buffer.\n */\n buffer: Buffer;\n}\n\n/**\n * Represents an object that is helpful in building a data url with support\n * for data encoding.\n */\nexport class ZDataUrlBuilder {\n /**\n * The representation of the data url object.\n */\n private _data: IZDataUrlInfo;\n\n /**\n * Initializes a new instance of this object.\n */\n public constructor() {\n this._data = {\n mimeType: '',\n encoding: 'utf8',\n buffer: Buffer.from('')\n };\n }\n\n /**\n * Parses an existing data url and sets all properties.\n *\n * @param url -\n * The url to parse.\n *\n * @returns\n * This object.\n */\n public parse(url: string): this {\n this._data = {\n mimeType: '',\n encoding: 'utf8',\n buffer: Buffer.from('')\n };\n\n if (!url.startsWith('data:')) {\n return this;\n }\n\n url = url.substring(5);\n const parts = url.split(',');\n\n if (parts.length < 2) {\n return this;\n }\n\n const [mimeType, ...bodyParts] = parts;\n let [type, ...params] = mimeType.split(';');\n\n const isBase64 = last(params) === 'base64';\n\n this._data.encoding = isBase64 ? 'base64' : 'utf8';\n\n if (isBase64) {\n params.pop();\n }\n\n if (!Object.hasOwnProperty.call(ZSupportedMimeTypes, type)) {\n type = ZMimeTypeApplication.OctetStream;\n params = [];\n }\n\n type = [type, ...params].join(';');\n\n this._data.mimeType = type;\n\n // Commas can be in the body. Type this into chrome and you can\n // see that chrome actually parses it: data:text/plain,cat,,,\n // We will support this here, but we're going to properly encode it.\n const body = bodyParts.join('%2C');\n this._data.buffer = isBase64 ? Buffer.from(body, 'base64') : Buffer.from(decodeURIComponent(body));\n return this;\n }\n\n /**\n * Sets the mime type.\n *\n * @param type -\n * The mime type.\n *\n * @returns\n * This object.\n */\n public mimeType(type: string): this {\n this._data.mimeType = type;\n return this;\n }\n\n /**\n * Sets the data buffer.\n *\n * @param data -\n * The data to set. If you pass a raw string, then the input encoding\n * is expected to be utf8.\n * @returns\n * This object.\n */\n public buffer(data: Buffer | string): this {\n this._data.buffer = typeof data === 'string' ? Buffer.from(data) : data;\n return this;\n }\n\n /**\n * Sets the output encoding.\n *\n * If you output encode the data as utf8, then it will be properly\n * escaped.\n *\n * @param encoding -\n * The output encoding.\n *\n * @returns\n * This object.\n */\n public encode(encoding: 'base64' | 'utf8'): this {\n this._data.encoding = encoding;\n return this;\n }\n\n /**\n * Builds the url string and returns it.\n *\n * @returns The url string.\n */\n public build(): string {\n const protocol = 'data';\n const modifier = this._data.encoding === 'base64' ? ';base64' : '';\n\n let raw = this._data.buffer.toString(this._data.encoding);\n\n if (this._data.encoding === 'utf8') {\n raw = encodeURIComponent(raw);\n\n // Note ! should be encoded as %21, but for uri's..it's not because\n // it's actually valid, but some servers don't accept ! as a character\n // and it must be encoded. Just fix it here.\n raw = raw.split('!').join('%21');\n }\n\n return `${protocol}:${this._data.mimeType}${modifier},${raw}`;\n }\n\n /**\n * Gets the current information about the url being built.\n *\n * @returns The current information about the url being built.\n */\n public info(): IZDataUrlInfo {\n const other = { ...this._data };\n other.buffer = this._data.buffer.slice();\n return other;\n }\n}\n","import { trim, trimEnd, trimStart } from 'lodash-es';\nimport URLParse from 'url-parse';\n\n/**\n * Represents information about a url.\n */\nexport interface IZUrlInfo {\n /**\n * The protocol for the url.\n */\n protocol: string;\n\n /**\n * The username.\n */\n username?: string;\n\n /**\n * The password.\n */\n password?: string;\n\n /**\n * The host.\n */\n hostname: string;\n\n /**\n * The port number.\n */\n port?: number;\n\n /**\n * A list of current paths.\n *\n * You can always get the full path using\n * path.join('/')\n */\n path: string[];\n\n /**\n * The client side hash route.\n */\n hash?: string;\n\n /**\n * The key value params.\n */\n params: Array<{ key: string; val: string }>;\n}\n\n/**\n * The api to target for YouTube.\n */\nexport enum ZYouTubeApi {\n /**\n * An embedded video link.\n */\n Embed = 'embed',\n /**\n * A watch video link.\n */\n Watch = 'watch'\n}\n\n/**\n * Represents an object that is helpful in building a url.\n */\nexport class ZUrlBuilder {\n /**\n * The url to the gravatar api.\n */\n public static UrlGravatar = 'https://s.gravatar.com/avatar';\n\n /**\n * The url to youtube.\n *\n * This is mostly used to embed videos.\n */\n public static UrlYouTube = 'https://www.youtube.com';\n\n /**\n * A mapping between protocol and default port.\n */\n public static ProtocolPorts = {\n http: 80,\n https: 443,\n ftp: 21,\n sftp: 22,\n ssh: 22,\n smtp: 25,\n smb: 445\n };\n\n /**\n * Gets whether the given protocols default port is port.\n *\n * The main purpose of this method is to determine if a url requires\n * a port section. Therefore, there are some special behaviors which may\n * not be obvious:\n *\n * 1. If the port is falsy then this method returns true.\n * 2. If the port is NaN, then this method returns true.\n * 3. If the port is a string that evaluates to 0, then this method returns true.\n * 4. If port is less than 0, then this method returns true.\n *\n * @param protocol -\n * The protocol to check.\n * @param port -\n * The port to compare.\n *\n * @returns\n * True if the default port for protocol is port.\n */\n public static defaults(protocol: string, port: string | number): boolean {\n const numericPort = +port;\n\n if (isNaN(numericPort) || numericPort < 1) {\n return true;\n }\n\n return ZUrlBuilder.ProtocolPorts[protocol] === +port;\n }\n\n /**\n * The representation of the url object.\n */\n private readonly _url: IZUrlInfo;\n\n /**\n * Initializes a new instance of this object.\n *\n * @param protocol -\n * The protocol to use.\n * @param hostname -\n * The hostname to connect with.\n */\n public constructor(protocol = 'http', hostname = 'localhost') {\n this._url = {\n protocol,\n hostname,\n path: ['/'],\n hash: '',\n params: []\n };\n }\n\n /**\n * Fills the information from the current location data.\n *\n * @param loc -\n * The optional location object to populate with.\n *\n * @returns\n * This object.\n */\n public location(loc: Location): this {\n this.protocol(loc.protocol).hostname(loc.hostname).hash(loc.hash).path(loc.pathname).port(+loc.port);\n\n let search = loc.search;\n\n if (search.startsWith('?')) {\n search = search.slice(1);\n const pairs = search.split('&');\n pairs.map((pair) => pair.split('=')).forEach((matrix) => this.param(matrix[0], matrix[1]));\n }\n\n return this;\n }\n\n /**\n * Fills the information for an api path call.\n *\n * This is a combination of location, hash with an empty string, and an\n * append of the basePath.\n *\n * @param loc -\n * The optional location object to populate with.\n * @param basePath -\n * The basePath for the api. Generally, it's best to\n * just keep this as api and have your server accept\n * this path.\n *\n * @returns\n * This object.\n */\n public api(loc: Location, basePath = 'api'): this {\n return this.location(loc).hash('').path(basePath);\n }\n\n /**\n * Parses an existing url and sets all properties.\n *\n * If you give this a path without the protocol and hostname, then it will\n * automatically append the protocol and host of the browser window if it\n * exists.\n *\n * This method sets all the properties so if you need to modify the url before\n * parsing it, it is best to always call this method first.\n *\n * @param url -\n * The url to parse.\n *\n * @returns\n * This object.\n */\n public parse(url: string) {\n const current = new URLParse(url, true);\n\n this.protocol(current.protocol)\n .username(current.username)\n .password(current.password)\n .hostname(current.hostname)\n .hash(current.hash)\n .path(current.pathname)\n .port(current.port ? +current.port : undefined);\n\n Object.keys(current.query).forEach((key) => this.param(key, current.query[key] as string));\n\n return this;\n }\n\n /**\n * Sets the url for a user gravatar.\n *\n * @param hash -\n * The md5 email hash.\n * @param size -\n * The dimensional size of the gravatar image.\n *\n * @returns\n * This object.\n */\n public gravatar(hash?: string, size?: number): this {\n let current = this.parse(ZUrlBuilder.UrlGravatar);\n current = hash ? current.append(hash) : current;\n current = size ? current.param('s', String(size)) : current;\n return current;\n }\n\n /**\n * Sets the url for a target video on YouTube.\n *\n * @param api -\n * The target api. If this is watch, then\n * it will be a target link to a youTube url.\n * If this is embed, then it will be a target\n * link that can be put into an iframe for\n * embedded youtube videos.\n * @param id -\n * The id of the video to watch.\n *\n * @returns\n * This object.\n */\n public youTube(api: ZYouTubeApi, id: string): this;\n\n /**\n * Sets the url to the base YouTube domain.\n *\n * @returns\n * This object.\n */\n public youTube(): this;\n\n /**\n * Sets the url target to something on YouTube.\n *\n * @param api -\n * The supported api.\n * @param id -\n * The id of the video. If api is set,\n * then this parameter is required.\n *\n * @returns\n * The url for YouTube. If you set the api and\n * id, then the url will be targeted to a specific video,\n * otherwise, the base domain url of YouTube will be returned.\n */\n public youTube(api?: ZYouTubeApi, id?: string) {\n let current = this.parse(ZUrlBuilder.UrlYouTube);\n current = api ? current.path(`${api}/${id}`) : current;\n\n // The watch api is a little bizarre that they don't actually\n // use the same format as their other apis. So we will handle this here.\n if (api === ZYouTubeApi.Watch) {\n current = current.path(api).param('v', id!);\n }\n\n return current;\n }\n\n /**\n * Sets the protocol.\n *\n * @param protocol -\n * The protocol.\n *\n * @returns\n * This object.\n */\n public protocol(protocol: string): this {\n this._url.protocol = protocol;\n return this;\n }\n\n /**\n * Sets the user name.\n *\n * Used for things like ssh and ftp.\n *\n * @param user -\n * The username\n *\n * @returns\n * This object.\n */\n public username(user: string | undefined): this {\n this._url.username = user;\n return this;\n }\n\n /**\n * Sets the password.\n *\n * This is only valid if the username is set.\n *\n * @param pwd -\n * The user password.\n *\n * @returns\n * This object.\n */\n public password(pwd: string | undefined): this {\n this._url.password = pwd;\n return this;\n }\n\n /**\n * Sets the host name.\n *\n * This sets the entire hostname as the root domain. This\n * will blow away any subdomains added, so it's best to\n * call this method first.\n *\n * @param host -\n * The hostname.\n *\n * @returns\n * This object.\n */\n public hostname(host: string): this {\n this._url.hostname = host;\n return this;\n }\n\n /**\n * Adds a subdomain in front of the hostname.\n *\n * If a hostname was never set, then domain becomes the hostname.\n *\n * @param domain -\n * The domain to append.\n *\n * @returns\n * This object.\n */\n public subdomain(domain: string): this {\n this._url.hostname = this._url.hostname ? `${domain}.${this._url.hostname}` : domain;\n return this;\n }\n\n /**\n * Removes a subdomain from the current domain.\n *\n * @returns\n * This object.\n */\n public popSubdomain(): this {\n const parts = this._url.hostname.split('.');\n parts.splice(0, 1);\n this._url.hostname = parts.join('.');\n return this;\n }\n\n /**\n * Sets the port.\n *\n * @param port -\n * The port.\n *\n * @returns\n * This object.\n */\n public port(port: number | undefined): this {\n this._url.port = port;\n return this;\n }\n\n /**\n * Removes all existing path segments and restarts the path.\n *\n * @param path -\n * The starting path.\n *\n * @returns\n * This object.\n */\n public path(path: string): this {\n this._url.path = [path];\n return this;\n }\n\n /**\n * Appends a path segment.\n *\n * @param path -\n * The segment to append.\n *\n * @returns\n * This object.\n */\n public append(path: string): this {\n this._url.path.push(path);\n return this;\n }\n\n /**\n * Sets the hash section.\n *\n * @param hash -\n * The hash section.\n *\n * @returns\n * This object.\n */\n public hash(hash: string | undefined): this {\n this._url.hash = hash;\n return this;\n }\n\n /**\n * Adds a search parameter.\n *\n * This version assumes that value is not null.\n *\n * @param key -\n * The parameter key.\n * @param val -\n * The parameter value.\n *\n * @returns\n * This object.\n */\n public param(key: string, val: string): this {\n this._url.params.push({ key, val });\n return this;\n }\n\n /**\n * Removes all duplicate params and adds one with the key to the value.\n *\n * @param key -\n * The parameter key that can have only one.\n * @param val -\n * The parameter value. If this is falsy, then\n * the key is deleted.\n */\n public onlyParam(key: string, val?: string): this {\n this._url.params = this._url.params.filter((p) => p.key !== key);\n return val ? this.param(key, val) : this;\n }\n\n /**\n * Adds a page param.\n *\n * @param page -\n * The page param to add. If this null, undefined,\n * or less than 1, then any page param is deleted.\n *\n * @returns\n * This object.\n */\n public page(page?: number | null): this {\n return this.onlyParam('page', page == null || page < 1 ? undefined : String(page));\n }\n\n /**\n * Adds a size param.\n *\n * @param size -\n * The size param to add. If this is null, undefined,\n * or less than 0, then any size param is deleted.\n *\n * @returns\n * This object.\n */\n public size(size?: number | null): this {\n return this.onlyParam('size', size == null || size < 0 ? undefined : String(size));\n }\n\n /**\n * Adds a search param.\n *\n * @param search -\n * The search param to add. If this is null, undefined,\n * or empty, then any search param is deleted.\n *\n * @returns\n * This object.\n */\n public search(search?: string | null): this {\n return this.onlyParam('search', search || undefined);\n }\n\n /**\n * Adds a filter param.\n *\n * @param filter -\n * The filter param to add. If this is null, undefined,\n * or empty, then any filter param is deleted.\n *\n * @returns\n * This object.\n */\n public filter(filter?: string | null): this {\n return this.onlyParam('filter', filter || undefined);\n }\n\n /**\n * Adds a sort param.\n *\n * @param sort -\n * The sort param to add. If this is null, undefined,\n * or empty, then any filter param is deleted.\n *\n * @returns\n * This object.\n */\n public sort(sort?: string | null): this {\n return this.onlyParam('sort', sort || undefined);\n }\n\n /**\n * Builds the url string and returns it.\n *\n * @returns\n * The url string.\n */\n public build(): string {\n const search = this._url.params.map((param) => `${param.key}=${encodeURIComponent(param.val)}`).join('&');\n const user = trim(this._url.username);\n const password = trim(this._url.password);\n let protocol = trim(this._url.protocol);\n let host = trim(this._url.hostname);\n let port = String(this._url.port);\n let hash = trim(this._url.hash);\n let path = this._url.path.map((segment) => trim(segment, '/')).join('/');\n let credentials = '';\n\n protocol = trimEnd(protocol, '/:');\n host = trim(host, '/');\n hash = trimStart(hash, '#');\n path = trim(path, '/');\n\n if (ZUrlBuilder.defaults(protocol, port)) {\n port = '';\n } else {\n port = `:${port}`;\n }\n\n if (user) {\n credentials = password ? `${user}:${password}@` : `${user}@`;\n }\n\n let url = `${protocol}://${credentials}${host}${port}`;\n\n if (path) {\n url = `${url}/${path}`;\n }\n\n if (search) {\n url = `${url}/?${search}`;\n }\n\n if (hash) {\n url = `${url}#${hash}`;\n }\n\n return url;\n }\n\n /**\n * Gets the current information about the uri being built.\n *\n * @returns The current uri information.\n */\n public info(): IZUrlInfo {\n return JSON.parse(JSON.stringify(this._url));\n }\n}\n"],"names":["ZMimeTypeApplication","ZMimeTypeImage","ZMimeTypeText","keyBy","Buffer","last","ZYouTubeApi","trim","trimEnd","trimStart"],"mappings":";;;;;;;;;;;AAKY,IAAA,yCAAAA,0BAAL;AAILA,wBAAA,MAAO,IAAA;AAOPA,wBAAA,aAAc,IAAA;AAKdA,wBAAA,KAAM,IAAA;AAhBIA,SAAAA;AAAA,GAAA,wBAAA,CAAA,CAAA;ACAA,IAAA,mCAAAC,oBAAL;AAKLA,kBAAA,MAAO,IAAA;AAUPA,kBAAA,MAAO,IAAA;AAMPA,kBAAA,KAAM,IAAA;AAONA,kBAAA,MAAO,IAAA;AAOPA,kBAAA,KAAM,IAAA;AAMNA,kBAAA,KAAM,IAAA;AAQNA,kBAAA,MAAO,IAAA;AAjDGA,SAAAA;AAAA,GAAA,kBAAA,CAAA,CAAA;ACAA,IAAA,kCAAAC,mBAAL;AAKLA,iBAAA,KAAM,IAAA;AAKNA,iBAAA,KAAM,IAAA;AAKNA,iBAAA,YAAa,IAAA;AAMbA,iBAAA,MAAO,IAAA;AAKPA,iBAAA,YAAa,IAAA;AAKbA,iBAAA,OAAQ,IAAA;AAQRA,iBAAA,KAAM,IAAA;AAvCIA,SAAAA;AAAA,GAAA,iBAAA,CAAA,CAAA;ACQC,MAAA,sBAAsB,OAAO,OAAO;AAAA,EAC/C,GAAG,EAAE,IAAI,2BAA2B;AAAA,EACpC,GAAGC,eAAM,OAAO,OAAO,oBAAoB,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EA,QAAI,QAAQ;AACJ,YAAA,GAAG,GAAG,KAAK,MAAM;AAAA,IACzB;AAEA,QAAI,MAAM;AACF,YAAA,GAAG,GAAG,IAAI,IAAI;AAAA,IACtB;AAEO,WAAA;AAAA,EACT;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOO,OAAkB;AACvB,WAAO,KAAK,MAAM,KAAK,UAAU,KAAK,IAAI,CAAC;AAAA,EAC7C;AACF;AAAA;AAAA;AAAA;AAhhBE,cAJW,cAIG,eAAc;AAAA;AAAA;AAAA;AAAA;AAAA;AAO5B,cAXW,cAWG,cAAa;AAAA;AAAA;AAAA;AAK3B,cAhBW,cAgBG,iBAAgB;AAAA,EAC5B,MAAM;AAAA,EACN,OAAO;AAAA,EACP,KAAK;AAAA,EACL,MAAM;AAAA,EACN,KAAK;AAAA,EACL,MAAM;AAAA,EACN,KAAK;AAAA;AAvBF,IAAM,cAAN;;;;;;;;"}
|
package/dist/index.js
CHANGED
|
@@ -521,7 +521,33 @@ const _ZUrlBuilder = class _ZUrlBuilder {
|
|
|
521
521
|
* This object.
|
|
522
522
|
*/
|
|
523
523
|
search(search) {
|
|
524
|
-
return this.onlyParam("search", search
|
|
524
|
+
return this.onlyParam("search", search || void 0);
|
|
525
|
+
}
|
|
526
|
+
/**
|
|
527
|
+
* Adds a filter param.
|
|
528
|
+
*
|
|
529
|
+
* @param filter -
|
|
530
|
+
* The filter param to add. If this is null, undefined,
|
|
531
|
+
* or empty, then any filter param is deleted.
|
|
532
|
+
*
|
|
533
|
+
* @returns
|
|
534
|
+
* This object.
|
|
535
|
+
*/
|
|
536
|
+
filter(filter) {
|
|
537
|
+
return this.onlyParam("filter", filter || void 0);
|
|
538
|
+
}
|
|
539
|
+
/**
|
|
540
|
+
* Adds a sort param.
|
|
541
|
+
*
|
|
542
|
+
* @param sort -
|
|
543
|
+
* The sort param to add. If this is null, undefined,
|
|
544
|
+
* or empty, then any filter param is deleted.
|
|
545
|
+
*
|
|
546
|
+
* @returns
|
|
547
|
+
* This object.
|
|
548
|
+
*/
|
|
549
|
+
sort(sort) {
|
|
550
|
+
return this.onlyParam("sort", sort || void 0);
|
|
525
551
|
}
|
|
526
552
|
/**
|
|
527
553
|
* Builds the url string and returns it.
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../src/mime/mime-type-application.mts","../src/mime/mime-type-image.mts","../src/mime/mime-type-text.mts","../src/mime/mime-type.mts","../src/data/data-url.mts","../src/url/url.mts"],"sourcesContent":["/* cspell:disable */\n\n/**\n * Application mime types.\n */\nexport enum ZMimeTypeApplication {\n /**\n * JSON data.\n */\n JSON = 'application/json',\n\n /**\n * The unknown type.\n *\n * Used for raw byte data.\n */\n OctetStream = 'application/octet-stream',\n\n /**\n * Compressed zip stream.\n */\n Zip = 'application/zip'\n}\n","/* cspell:disable */\n\n/**\n * Mime types for images.\n */\nexport enum ZMimeTypeImage {\n /**\n * Good choice for lossless animation sequences (GIF is less performant). AVIF and\n * WebP have better performance but less broad browser support.\n */\n APNG = 'image/apng',\n\n /**\n * Good choice for both images and animated images due to high performance and\n * royalty free image format. It offers much better compression than PNG or JPEG\n * with support for higher color depths, animated frames, transparency etc.\n *\n * Note that when using AVIF, you should include fallbacks to formats with\n * better browser support (i.e. using the <picture> element).\n */\n AVIF = 'image/avif',\n\n /**\n * Good choice for simple images and animations. Prefer PNG for lossless and\n * indexed still images, and consider WebP, AVIF or APNG for animation sequences.\n */\n GIF = 'image/gif',\n\n /**\n * Good choice for lossy compression of still images (currently the most popular). Prefer\n * PNG when more precise reproduction of the image is required, or WebP/AVIF if both better\n * reproduction and higher compression are required.\n */\n JPEG = 'image/jpeg',\n\n /**\n * PNG is preferred over JPEG for more precise reproduction of source images, or when\n * transparency is needed. WebP/AVIF provide even better compression and reproduction,\n * but browser support is more limited.\n */\n PNG = 'image/png',\n\n /**\n * Vector image format; ideal for user interface elements, icons, diagrams, etc., that\n * must be drawn accurately at different sizes.\n */\n SVG = 'image/svg+xml',\n\n /**\n * Excellent choice for both images and animated images. WebP offers much better compression\n * than PNG or JPEG with support for higher color depths, animated frames, transparency etc.\n * AVIF offers slightly better compression, but is not quite as well-supported in browsers\n * and does not support progressive rendering.\n */\n WebP = 'image/webp'\n}\n","/* cspell:disable */\n\n/**\n * Mime types for text based data.\n */\nexport enum ZMimeTypeText {\n /**\n * Style files used in html documents must be sent as\n * css.\n */\n CSS = 'text/css',\n\n /**\n * Comma separated values.\n */\n CSV = 'text/csv',\n\n /**\n * JavaScript.\n */\n EcmaScript = 'text/ecmascript',\n\n /**\n * Hyper Text Markup Language. Markup language for\n * web pages.\n */\n HTML = 'text/html',\n\n /**\n * JavaScript.\n */\n JavaScript = 'text/javascript',\n\n /**\n * Plain (basic) text.\n */\n Plain = 'text/plain',\n\n /**\n * Xtreme Markup Language.\n *\n * Superset of HTML. Bulky, but can\n * represent anything.\n */\n XML = 'text/xml'\n}\n","import { keyBy } from 'lodash-es';\nimport { ZMimeTypeApplication } from './mime-type-application.mjs';\nimport { ZMimeTypeImage } from './mime-type-image.mjs';\nimport { ZMimeTypeText } from './mime-type-text.mjs';\n\n/**\n * Mime types for file data.\n */\nexport type ZMimeType = ZMimeTypeApplication | ZMimeTypeText | ZMimeTypeImage;\n\n/**\n * A mapping of supported mime types.\n */\nexport const ZSupportedMimeTypes = Object.freeze({\n ...{ '': 'text/plain;charset=ASCII' },\n ...keyBy(Object.values(ZMimeTypeApplication)),\n ...keyBy(Object.values(ZMimeTypeText)),\n ...keyBy(Object.values(ZMimeTypeImage))\n});\n","import { Buffer } from 'buffer';\nimport { last } from 'lodash-es';\nimport { ZMimeTypeApplication } from '../mime/mime-type-application.mjs';\nimport { ZSupportedMimeTypes } from '../mime/mime-type.mjs';\n\n/**\n * Represents information about a data url.\n */\nexport interface IZDataUrlInfo {\n /**\n * The content information mime type.\n */\n mimeType: string;\n\n /**\n * The output encoding.\n */\n encoding: 'base64' | 'utf8';\n\n /**\n * The raw data buffer.\n */\n buffer: Buffer;\n}\n\n/**\n * Represents an object that is helpful in building a data url with support\n * for data encoding.\n */\nexport class ZDataUrlBuilder {\n /**\n * The representation of the data url object.\n */\n private _data: IZDataUrlInfo;\n\n /**\n * Initializes a new instance of this object.\n */\n public constructor() {\n this._data = {\n mimeType: '',\n encoding: 'utf8',\n buffer: Buffer.from('')\n };\n }\n\n /**\n * Parses an existing data url and sets all properties.\n *\n * @param url -\n * The url to parse.\n *\n * @returns\n * This object.\n */\n public parse(url: string): this {\n this._data = {\n mimeType: '',\n encoding: 'utf8',\n buffer: Buffer.from('')\n };\n\n if (!url.startsWith('data:')) {\n return this;\n }\n\n url = url.substring(5);\n const parts = url.split(',');\n\n if (parts.length < 2) {\n return this;\n }\n\n const [mimeType, ...bodyParts] = parts;\n let [type, ...params] = mimeType.split(';');\n\n const isBase64 = last(params) === 'base64';\n\n this._data.encoding = isBase64 ? 'base64' : 'utf8';\n\n if (isBase64) {\n params.pop();\n }\n\n if (!Object.hasOwnProperty.call(ZSupportedMimeTypes, type)) {\n type = ZMimeTypeApplication.OctetStream;\n params = [];\n }\n\n type = [type, ...params].join(';');\n\n this._data.mimeType = type;\n\n // Commas can be in the body. Type this into chrome and you can\n // see that chrome actually parses it: data:text/plain,cat,,,\n // We will support this here, but we're going to properly encode it.\n const body = bodyParts.join('%2C');\n this._data.buffer = isBase64 ? Buffer.from(body, 'base64') : Buffer.from(decodeURIComponent(body));\n return this;\n }\n\n /**\n * Sets the mime type.\n *\n * @param type -\n * The mime type.\n *\n * @returns\n * This object.\n */\n public mimeType(type: string): this {\n this._data.mimeType = type;\n return this;\n }\n\n /**\n * Sets the data buffer.\n *\n * @param data -\n * The data to set. If you pass a raw string, then the input encoding\n * is expected to be utf8.\n * @returns\n * This object.\n */\n public buffer(data: Buffer | string): this {\n this._data.buffer = typeof data === 'string' ? Buffer.from(data) : data;\n return this;\n }\n\n /**\n * Sets the output encoding.\n *\n * If you output encode the data as utf8, then it will be properly\n * escaped.\n *\n * @param encoding -\n * The output encoding.\n *\n * @returns\n * This object.\n */\n public encode(encoding: 'base64' | 'utf8'): this {\n this._data.encoding = encoding;\n return this;\n }\n\n /**\n * Builds the url string and returns it.\n *\n * @returns The url string.\n */\n public build(): string {\n const protocol = 'data';\n const modifier = this._data.encoding === 'base64' ? ';base64' : '';\n\n let raw = this._data.buffer.toString(this._data.encoding);\n\n if (this._data.encoding === 'utf8') {\n raw = encodeURIComponent(raw);\n\n // Note ! should be encoded as %21, but for uri's..it's not because\n // it's actually valid, but some servers don't accept ! as a character\n // and it must be encoded. Just fix it here.\n raw = raw.split('!').join('%21');\n }\n\n return `${protocol}:${this._data.mimeType}${modifier},${raw}`;\n }\n\n /**\n * Gets the current information about the url being built.\n *\n * @returns The current information about the url being built.\n */\n public info(): IZDataUrlInfo {\n const other = { ...this._data };\n other.buffer = this._data.buffer.slice();\n return other;\n }\n}\n","import { trim, trimEnd, trimStart } from 'lodash-es';\nimport URLParse from 'url-parse';\n\n/**\n * Represents information about a url.\n */\nexport interface IZUrlInfo {\n /**\n * The protocol for the url.\n */\n protocol: string;\n\n /**\n * The username.\n */\n username?: string;\n\n /**\n * The password.\n */\n password?: string;\n\n /**\n * The host.\n */\n hostname: string;\n\n /**\n * The port number.\n */\n port?: number;\n\n /**\n * A list of current paths.\n *\n * You can always get the full path using\n * path.join('/')\n */\n path: string[];\n\n /**\n * The client side hash route.\n */\n hash?: string;\n\n /**\n * The key value params.\n */\n params: Array<{ key: string; val: string }>;\n}\n\n/**\n * The api to target for YouTube.\n */\nexport enum ZYouTubeApi {\n /**\n * An embedded video link.\n */\n Embed = 'embed',\n /**\n * A watch video link.\n */\n Watch = 'watch'\n}\n\n/**\n * Represents an object that is helpful in building a url.\n */\nexport class ZUrlBuilder {\n /**\n * The url to the gravatar api.\n */\n public static UrlGravatar = 'https://s.gravatar.com/avatar';\n\n /**\n * The url to youtube.\n *\n * This is mostly used to embed videos.\n */\n public static UrlYouTube = 'https://www.youtube.com';\n\n /**\n * A mapping between protocol and default port.\n */\n public static ProtocolPorts = {\n http: 80,\n https: 443,\n ftp: 21,\n sftp: 22,\n ssh: 22,\n smtp: 25,\n smb: 445\n };\n\n /**\n * Gets whether the given protocols default port is port.\n *\n * The main purpose of this method is to determine if a url requires\n * a port section. Therefore, there are some special behaviors which may\n * not be obvious:\n *\n * 1. If the port is falsy then this method returns true.\n * 2. If the port is NaN, then this method returns true.\n * 3. If the port is a string that evaluates to 0, then this method returns true.\n * 4. If port is less than 0, then this method returns true.\n *\n * @param protocol -\n * The protocol to check.\n * @param port -\n * The port to compare.\n *\n * @returns\n * True if the default port for protocol is port.\n */\n public static defaults(protocol: string, port: string | number): boolean {\n const numericPort = +port;\n\n if (isNaN(numericPort) || numericPort < 1) {\n return true;\n }\n\n return ZUrlBuilder.ProtocolPorts[protocol] === +port;\n }\n\n /**\n * The representation of the url object.\n */\n private readonly _url: IZUrlInfo;\n\n /**\n * Initializes a new instance of this object.\n *\n * @param protocol -\n * The protocol to use.\n * @param hostname -\n * The hostname to connect with.\n */\n public constructor(protocol = 'http', hostname = 'localhost') {\n this._url = {\n protocol,\n hostname,\n path: ['/'],\n hash: '',\n params: []\n };\n }\n\n /**\n * Fills the information from the current location data.\n *\n * @param loc -\n * The optional location object to populate with.\n *\n * @returns\n * This object.\n */\n public location(loc: Location): this {\n this.protocol(loc.protocol).hostname(loc.hostname).hash(loc.hash).path(loc.pathname).port(+loc.port);\n\n let search = loc.search;\n\n if (search.startsWith('?')) {\n search = search.slice(1);\n const pairs = search.split('&');\n pairs.map((pair) => pair.split('=')).forEach((matrix) => this.param(matrix[0], matrix[1]));\n }\n\n return this;\n }\n\n /**\n * Fills the information for an api path call.\n *\n * This is a combination of location, hash with an empty string, and an\n * append of the basePath.\n *\n * @param loc -\n * The optional location object to populate with.\n * @param basePath -\n * The basePath for the api. Generally, it's best to\n * just keep this as api and have your server accept\n * this path.\n *\n * @returns\n * This object.\n */\n public api(loc: Location, basePath = 'api'): this {\n return this.location(loc).hash('').path(basePath);\n }\n\n /**\n * Parses an existing url and sets all properties.\n *\n * If you give this a path without the protocol and hostname, then it will\n * automatically append the protocol and host of the browser window if it\n * exists.\n *\n * This method sets all the properties so if you need to modify the url before\n * parsing it, it is best to always call this method first.\n *\n * @param url -\n * The url to parse.\n *\n * @returns\n * This object.\n */\n public parse(url: string) {\n const current = new URLParse(url, true);\n\n this.protocol(current.protocol)\n .username(current.username)\n .password(current.password)\n .hostname(current.hostname)\n .hash(current.hash)\n .path(current.pathname)\n .port(current.port ? +current.port : undefined);\n\n Object.keys(current.query).forEach((key) => this.param(key, current.query[key] as string));\n\n return this;\n }\n\n /**\n * Sets the url for a user gravatar.\n *\n * @param hash -\n * The md5 email hash.\n * @param size -\n * The dimensional size of the gravatar image.\n *\n * @returns\n * This object.\n */\n public gravatar(hash?: string, size?: number): this {\n let current = this.parse(ZUrlBuilder.UrlGravatar);\n current = hash ? current.append(hash) : current;\n current = size ? current.param('s', String(size)) : current;\n return current;\n }\n\n /**\n * Sets the url for a target video on YouTube.\n *\n * @param api -\n * The target api. If this is watch, then\n * it will be a target link to a youTube url.\n * If this is embed, then it will be a target\n * link that can be put into an iframe for\n * embedded youtube videos.\n * @param id -\n * The id of the video to watch.\n *\n * @returns\n * This object.\n */\n public youTube(api: ZYouTubeApi, id: string): this;\n\n /**\n * Sets the url to the base YouTube domain.\n *\n * @returns\n * This object.\n */\n public youTube(): this;\n\n /**\n * Sets the url target to something on YouTube.\n *\n * @param api -\n * The supported api.\n * @param id -\n * The id of the video. If api is set,\n * then this parameter is required.\n *\n * @returns\n * The url for YouTube. If you set the api and\n * id, then the url will be targeted to a specific video,\n * otherwise, the base domain url of YouTube will be returned.\n */\n public youTube(api?: ZYouTubeApi, id?: string) {\n let current = this.parse(ZUrlBuilder.UrlYouTube);\n current = api ? current.path(`${api}/${id}`) : current;\n\n // The watch api is a little bizarre that they don't actually\n // use the same format as their other apis. So we will handle this here.\n if (api === ZYouTubeApi.Watch) {\n current = current.path(api).param('v', id!);\n }\n\n return current;\n }\n\n /**\n * Sets the protocol.\n *\n * @param protocol -\n * The protocol.\n *\n * @returns\n * This object.\n */\n public protocol(protocol: string): this {\n this._url.protocol = protocol;\n return this;\n }\n\n /**\n * Sets the user name.\n *\n * Used for things like ssh and ftp.\n *\n * @param user -\n * The username\n *\n * @returns\n * This object.\n */\n public username(user: string | undefined): this {\n this._url.username = user;\n return this;\n }\n\n /**\n * Sets the password.\n *\n * This is only valid if the username is set.\n *\n * @param pwd -\n * The user password.\n *\n * @returns\n * This object.\n */\n public password(pwd: string | undefined): this {\n this._url.password = pwd;\n return this;\n }\n\n /**\n * Sets the host name.\n *\n * This sets the entire hostname as the root domain. This\n * will blow away any subdomains added, so it's best to\n * call this method first.\n *\n * @param host -\n * The hostname.\n *\n * @returns\n * This object.\n */\n public hostname(host: string): this {\n this._url.hostname = host;\n return this;\n }\n\n /**\n * Adds a subdomain in front of the hostname.\n *\n * If a hostname was never set, then domain becomes the hostname.\n *\n * @param domain -\n * The domain to append.\n *\n * @returns\n * This object.\n */\n public subdomain(domain: string): this {\n this._url.hostname = this._url.hostname ? `${domain}.${this._url.hostname}` : domain;\n return this;\n }\n\n /**\n * Removes a subdomain from the current domain.\n *\n * @returns\n * This object.\n */\n public popSubdomain(): this {\n const parts = this._url.hostname.split('.');\n parts.splice(0, 1);\n this._url.hostname = parts.join('.');\n return this;\n }\n\n /**\n * Sets the port.\n *\n * @param port -\n * The port.\n *\n * @returns\n * This object.\n */\n public port(port: number | undefined): this {\n this._url.port = port;\n return this;\n }\n\n /**\n * Removes all existing path segments and restarts the path.\n *\n * @param path -\n * The starting path.\n *\n * @returns\n * This object.\n */\n public path(path: string): this {\n this._url.path = [path];\n return this;\n }\n\n /**\n * Appends a path segment.\n *\n * @param path -\n * The segment to append.\n *\n * @returns\n * This object.\n */\n public append(path: string): this {\n this._url.path.push(path);\n return this;\n }\n\n /**\n * Sets the hash section.\n *\n * @param hash -\n * The hash section.\n *\n * @returns\n * This object.\n */\n public hash(hash: string | undefined): this {\n this._url.hash = hash;\n return this;\n }\n\n /**\n * Adds a search parameter.\n *\n * This version assumes that value is not null.\n *\n * @param key -\n * The parameter key.\n * @param val -\n * The parameter value.\n *\n * @returns\n * This object.\n */\n public param(key: string, val: string): this {\n this._url.params.push({ key, val });\n return this;\n }\n\n /**\n * Removes all duplicate params and adds one with the key to the value.\n *\n * @param key -\n * The parameter key that can have only one.\n * @param val -\n * The parameter value. If this is falsy, then\n * the key is deleted.\n */\n public onlyParam(key: string, val?: string): this {\n this._url.params = this._url.params.filter((p) => p.key !== key);\n return val ? this.param(key, val) : this;\n }\n\n /**\n * Adds a page param.\n *\n * @param page -\n * The page param to add. If this null, undefined,\n * or less than 1, then any page param is deleted.\n *\n * @returns\n * This object.\n */\n public page(page?: number | null): this {\n return this.onlyParam('page', page == null || page < 1 ? undefined : String(page));\n }\n\n /**\n * Adds a size param.\n *\n * @param size -\n * The size param to add. If this is null, undefined,\n * or less than 0, then any size param is deleted.\n *\n * @returns\n * This object.\n */\n public size(size?: number | null): this {\n return this.onlyParam('size', size == null || size < 0 ? undefined : String(size));\n }\n\n /**\n * Adds a search param.\n *\n * @param search -\n * The search param to add. If this is null, undefined,\n * or empty, then any search param is deleted.\n *\n * @returns\n * This object.\n */\n public search(search?: string | null): this {\n return this.onlyParam('search', search ? search : undefined);\n }\n\n /**\n * Builds the url string and returns it.\n *\n * @returns\n * The url string.\n */\n public build(): string {\n const search = this._url.params.map((param) => `${param.key}=${encodeURIComponent(param.val)}`).join('&');\n const user = trim(this._url.username);\n const password = trim(this._url.password);\n let protocol = trim(this._url.protocol);\n let host = trim(this._url.hostname);\n let port = String(this._url.port);\n let hash = trim(this._url.hash);\n let path = this._url.path.map((segment) => trim(segment, '/')).join('/');\n let credentials = '';\n\n protocol = trimEnd(protocol, '/:');\n host = trim(host, '/');\n hash = trimStart(hash, '#');\n path = trim(path, '/');\n\n if (ZUrlBuilder.defaults(protocol, port)) {\n port = '';\n } else {\n port = `:${port}`;\n }\n\n if (user) {\n credentials = password ? `${user}:${password}@` : `${user}@`;\n }\n\n let url = `${protocol}://${credentials}${host}${port}`;\n\n if (path) {\n url = `${url}/${path}`;\n }\n\n if (search) {\n url = `${url}/?${search}`;\n }\n\n if (hash) {\n url = `${url}#${hash}`;\n }\n\n return url;\n }\n\n /**\n * Gets the current information about the uri being built.\n *\n * @returns The current uri information.\n */\n public info(): IZUrlInfo {\n return JSON.parse(JSON.stringify(this._url));\n }\n}\n"],"names":["ZMimeTypeApplication","ZMimeTypeImage","ZMimeTypeText","Buffer","ZYouTubeApi"],"mappings":";;;;;;;;;AAKY,IAAA,yCAAAA,0BAAL;AAILA,wBAAA,MAAO,IAAA;AAOPA,wBAAA,aAAc,IAAA;AAKdA,wBAAA,KAAM,IAAA;AAhBIA,SAAAA;AAAA,GAAA,wBAAA,CAAA,CAAA;ACAA,IAAA,mCAAAC,oBAAL;AAKLA,kBAAA,MAAO,IAAA;AAUPA,kBAAA,MAAO,IAAA;AAMPA,kBAAA,KAAM,IAAA;AAONA,kBAAA,MAAO,IAAA;AAOPA,kBAAA,KAAM,IAAA;AAMNA,kBAAA,KAAM,IAAA;AAQNA,kBAAA,MAAO,IAAA;AAjDGA,SAAAA;AAAA,GAAA,kBAAA,CAAA,CAAA;ACAA,IAAA,kCAAAC,mBAAL;AAKLA,iBAAA,KAAM,IAAA;AAKNA,iBAAA,KAAM,IAAA;AAKNA,iBAAA,YAAa,IAAA;AAMbA,iBAAA,MAAO,IAAA;AAKPA,iBAAA,YAAa,IAAA;AAKbA,iBAAA,OAAQ,IAAA;AAQRA,iBAAA,KAAM,IAAA;AAvCIA,SAAAA;AAAA,GAAA,iBAAA,CAAA,CAAA;ACQC,MAAA,sBAAsB,OAAO,OAAO;AAAA,EAC/C,GAAG,EAAE,IAAI,2BAA2B;AAAA,EACpC,GAAG,MAAM,OAAO,OAAO,oBAAoB,CAAC;AAAA,EAC5C,GAAG,MAAM,OAAO,OAAO,aAAa,CAAC;AAA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O;AAAA,EACP,KAAK;AAAA,EACL,MAAM;AAAA,EACN,KAAK;AAAA,EACL,MAAM;AAAA,EACN,KAAK;AAAA;AAvBF,IAAM,cAAN;"}
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../src/mime/mime-type-application.mts","../src/mime/mime-type-image.mts","../src/mime/mime-type-text.mts","../src/mime/mime-type.mts","../src/data/data-url.mts","../src/url/url.mts"],"sourcesContent":["/* cspell:disable */\n\n/**\n * Application mime types.\n */\nexport enum ZMimeTypeApplication {\n /**\n * JSON data.\n */\n JSON = 'application/json',\n\n /**\n * The unknown type.\n *\n * Used for raw byte data.\n */\n OctetStream = 'application/octet-stream',\n\n /**\n * Compressed zip stream.\n */\n Zip = 'application/zip'\n}\n","/* cspell:disable */\n\n/**\n * Mime types for images.\n */\nexport enum ZMimeTypeImage {\n /**\n * Good choice for lossless animation sequences (GIF is less performant). AVIF and\n * WebP have better performance but less broad browser support.\n */\n APNG = 'image/apng',\n\n /**\n * Good choice for both images and animated images due to high performance and\n * royalty free image format. It offers much better compression than PNG or JPEG\n * with support for higher color depths, animated frames, transparency etc.\n *\n * Note that when using AVIF, you should include fallbacks to formats with\n * better browser support (i.e. using the <picture> element).\n */\n AVIF = 'image/avif',\n\n /**\n * Good choice for simple images and animations. Prefer PNG for lossless and\n * indexed still images, and consider WebP, AVIF or APNG for animation sequences.\n */\n GIF = 'image/gif',\n\n /**\n * Good choice for lossy compression of still images (currently the most popular). Prefer\n * PNG when more precise reproduction of the image is required, or WebP/AVIF if both better\n * reproduction and higher compression are required.\n */\n JPEG = 'image/jpeg',\n\n /**\n * PNG is preferred over JPEG for more precise reproduction of source images, or when\n * transparency is needed. WebP/AVIF provide even better compression and reproduction,\n * but browser support is more limited.\n */\n PNG = 'image/png',\n\n /**\n * Vector image format; ideal for user interface elements, icons, diagrams, etc., that\n * must be drawn accurately at different sizes.\n */\n SVG = 'image/svg+xml',\n\n /**\n * Excellent choice for both images and animated images. WebP offers much better compression\n * than PNG or JPEG with support for higher color depths, animated frames, transparency etc.\n * AVIF offers slightly better compression, but is not quite as well-supported in browsers\n * and does not support progressive rendering.\n */\n WebP = 'image/webp'\n}\n","/* cspell:disable */\n\n/**\n * Mime types for text based data.\n */\nexport enum ZMimeTypeText {\n /**\n * Style files used in html documents must be sent as\n * css.\n */\n CSS = 'text/css',\n\n /**\n * Comma separated values.\n */\n CSV = 'text/csv',\n\n /**\n * JavaScript.\n */\n EcmaScript = 'text/ecmascript',\n\n /**\n * Hyper Text Markup Language. Markup language for\n * web pages.\n */\n HTML = 'text/html',\n\n /**\n * JavaScript.\n */\n JavaScript = 'text/javascript',\n\n /**\n * Plain (basic) text.\n */\n Plain = 'text/plain',\n\n /**\n * Xtreme Markup Language.\n *\n * Superset of HTML. Bulky, but can\n * represent anything.\n */\n XML = 'text/xml'\n}\n","import { keyBy } from 'lodash-es';\nimport { ZMimeTypeApplication } from './mime-type-application.mjs';\nimport { ZMimeTypeImage } from './mime-type-image.mjs';\nimport { ZMimeTypeText } from './mime-type-text.mjs';\n\n/**\n * Mime types for file data.\n */\nexport type ZMimeType = ZMimeTypeApplication | ZMimeTypeText | ZMimeTypeImage;\n\n/**\n * A mapping of supported mime types.\n */\nexport const ZSupportedMimeTypes = Object.freeze({\n ...{ '': 'text/plain;charset=ASCII' },\n ...keyBy(Object.values(ZMimeTypeApplication)),\n ...keyBy(Object.values(ZMimeTypeText)),\n ...keyBy(Object.values(ZMimeTypeImage))\n});\n","import { Buffer } from 'buffer';\nimport { last } from 'lodash-es';\nimport { ZMimeTypeApplication } from '../mime/mime-type-application.mjs';\nimport { ZSupportedMimeTypes } from '../mime/mime-type.mjs';\n\n/**\n * Represents information about a data url.\n */\nexport interface IZDataUrlInfo {\n /**\n * The content information mime type.\n */\n mimeType: string;\n\n /**\n * The output encoding.\n */\n encoding: 'base64' | 'utf8';\n\n /**\n * The raw data buffer.\n */\n buffer: Buffer;\n}\n\n/**\n * Represents an object that is helpful in building a data url with support\n * for data encoding.\n */\nexport class ZDataUrlBuilder {\n /**\n * The representation of the data url object.\n */\n private _data: IZDataUrlInfo;\n\n /**\n * Initializes a new instance of this object.\n */\n public constructor() {\n this._data = {\n mimeType: '',\n encoding: 'utf8',\n buffer: Buffer.from('')\n };\n }\n\n /**\n * Parses an existing data url and sets all properties.\n *\n * @param url -\n * The url to parse.\n *\n * @returns\n * This object.\n */\n public parse(url: string): this {\n this._data = {\n mimeType: '',\n encoding: 'utf8',\n buffer: Buffer.from('')\n };\n\n if (!url.startsWith('data:')) {\n return this;\n }\n\n url = url.substring(5);\n const parts = url.split(',');\n\n if (parts.length < 2) {\n return this;\n }\n\n const [mimeType, ...bodyParts] = parts;\n let [type, ...params] = mimeType.split(';');\n\n const isBase64 = last(params) === 'base64';\n\n this._data.encoding = isBase64 ? 'base64' : 'utf8';\n\n if (isBase64) {\n params.pop();\n }\n\n if (!Object.hasOwnProperty.call(ZSupportedMimeTypes, type)) {\n type = ZMimeTypeApplication.OctetStream;\n params = [];\n }\n\n type = [type, ...params].join(';');\n\n this._data.mimeType = type;\n\n // Commas can be in the body. Type this into chrome and you can\n // see that chrome actually parses it: data:text/plain,cat,,,\n // We will support this here, but we're going to properly encode it.\n const body = bodyParts.join('%2C');\n this._data.buffer = isBase64 ? Buffer.from(body, 'base64') : Buffer.from(decodeURIComponent(body));\n return this;\n }\n\n /**\n * Sets the mime type.\n *\n * @param type -\n * The mime type.\n *\n * @returns\n * This object.\n */\n public mimeType(type: string): this {\n this._data.mimeType = type;\n return this;\n }\n\n /**\n * Sets the data buffer.\n *\n * @param data -\n * The data to set. If you pass a raw string, then the input encoding\n * is expected to be utf8.\n * @returns\n * This object.\n */\n public buffer(data: Buffer | string): this {\n this._data.buffer = typeof data === 'string' ? Buffer.from(data) : data;\n return this;\n }\n\n /**\n * Sets the output encoding.\n *\n * If you output encode the data as utf8, then it will be properly\n * escaped.\n *\n * @param encoding -\n * The output encoding.\n *\n * @returns\n * This object.\n */\n public encode(encoding: 'base64' | 'utf8'): this {\n this._data.encoding = encoding;\n return this;\n }\n\n /**\n * Builds the url string and returns it.\n *\n * @returns The url string.\n */\n public build(): string {\n const protocol = 'data';\n const modifier = this._data.encoding === 'base64' ? ';base64' : '';\n\n let raw = this._data.buffer.toString(this._data.encoding);\n\n if (this._data.encoding === 'utf8') {\n raw = encodeURIComponent(raw);\n\n // Note ! should be encoded as %21, but for uri's..it's not because\n // it's actually valid, but some servers don't accept ! as a character\n // and it must be encoded. Just fix it here.\n raw = raw.split('!').join('%21');\n }\n\n return `${protocol}:${this._data.mimeType}${modifier},${raw}`;\n }\n\n /**\n * Gets the current information about the url being built.\n *\n * @returns The current information about the url being built.\n */\n public info(): IZDataUrlInfo {\n const other = { ...this._data };\n other.buffer = this._data.buffer.slice();\n return other;\n }\n}\n","import { trim, trimEnd, trimStart } from 'lodash-es';\nimport URLParse from 'url-parse';\n\n/**\n * Represents information about a url.\n */\nexport interface IZUrlInfo {\n /**\n * The protocol for the url.\n */\n protocol: string;\n\n /**\n * The username.\n */\n username?: string;\n\n /**\n * The password.\n */\n password?: string;\n\n /**\n * The host.\n */\n hostname: string;\n\n /**\n * The port number.\n */\n port?: number;\n\n /**\n * A list of current paths.\n *\n * You can always get the full path using\n * path.join('/')\n */\n path: string[];\n\n /**\n * The client side hash route.\n */\n hash?: string;\n\n /**\n * The key value params.\n */\n params: Array<{ key: string; val: string }>;\n}\n\n/**\n * The api to target for YouTube.\n */\nexport enum ZYouTubeApi {\n /**\n * An embedded video link.\n */\n Embed = 'embed',\n /**\n * A watch video link.\n */\n Watch = 'watch'\n}\n\n/**\n * Represents an object that is helpful in building a url.\n */\nexport class ZUrlBuilder {\n /**\n * The url to the gravatar api.\n */\n public static UrlGravatar = 'https://s.gravatar.com/avatar';\n\n /**\n * The url to youtube.\n *\n * This is mostly used to embed videos.\n */\n public static UrlYouTube = 'https://www.youtube.com';\n\n /**\n * A mapping between protocol and default port.\n */\n public static ProtocolPorts = {\n http: 80,\n https: 443,\n ftp: 21,\n sftp: 22,\n ssh: 22,\n smtp: 25,\n smb: 445\n };\n\n /**\n * Gets whether the given protocols default port is port.\n *\n * The main purpose of this method is to determine if a url requires\n * a port section. Therefore, there are some special behaviors which may\n * not be obvious:\n *\n * 1. If the port is falsy then this method returns true.\n * 2. If the port is NaN, then this method returns true.\n * 3. If the port is a string that evaluates to 0, then this method returns true.\n * 4. If port is less than 0, then this method returns true.\n *\n * @param protocol -\n * The protocol to check.\n * @param port -\n * The port to compare.\n *\n * @returns\n * True if the default port for protocol is port.\n */\n public static defaults(protocol: string, port: string | number): boolean {\n const numericPort = +port;\n\n if (isNaN(numericPort) || numericPort < 1) {\n return true;\n }\n\n return ZUrlBuilder.ProtocolPorts[protocol] === +port;\n }\n\n /**\n * The representation of the url object.\n */\n private readonly _url: IZUrlInfo;\n\n /**\n * Initializes a new instance of this object.\n *\n * @param protocol -\n * The protocol to use.\n * @param hostname -\n * The hostname to connect with.\n */\n public constructor(protocol = 'http', hostname = 'localhost') {\n this._url = {\n protocol,\n hostname,\n path: ['/'],\n hash: '',\n params: []\n };\n }\n\n /**\n * Fills the information from the current location data.\n *\n * @param loc -\n * The optional location object to populate with.\n *\n * @returns\n * This object.\n */\n public location(loc: Location): this {\n this.protocol(loc.protocol).hostname(loc.hostname).hash(loc.hash).path(loc.pathname).port(+loc.port);\n\n let search = loc.search;\n\n if (search.startsWith('?')) {\n search = search.slice(1);\n const pairs = search.split('&');\n pairs.map((pair) => pair.split('=')).forEach((matrix) => this.param(matrix[0], matrix[1]));\n }\n\n return this;\n }\n\n /**\n * Fills the information for an api path call.\n *\n * This is a combination of location, hash with an empty string, and an\n * append of the basePath.\n *\n * @param loc -\n * The optional location object to populate with.\n * @param basePath -\n * The basePath for the api. Generally, it's best to\n * just keep this as api and have your server accept\n * this path.\n *\n * @returns\n * This object.\n */\n public api(loc: Location, basePath = 'api'): this {\n return this.location(loc).hash('').path(basePath);\n }\n\n /**\n * Parses an existing url and sets all properties.\n *\n * If you give this a path without the protocol and hostname, then it will\n * automatically append the protocol and host of the browser window if it\n * exists.\n *\n * This method sets all the properties so if you need to modify the url before\n * parsing it, it is best to always call this method first.\n *\n * @param url -\n * The url to parse.\n *\n * @returns\n * This object.\n */\n public parse(url: string) {\n const current = new URLParse(url, true);\n\n this.protocol(current.protocol)\n .username(current.username)\n .password(current.password)\n .hostname(current.hostname)\n .hash(current.hash)\n .path(current.pathname)\n .port(current.port ? +current.port : undefined);\n\n Object.keys(current.query).forEach((key) => this.param(key, current.query[key] as string));\n\n return this;\n }\n\n /**\n * Sets the url for a user gravatar.\n *\n * @param hash -\n * The md5 email hash.\n * @param size -\n * The dimensional size of the gravatar image.\n *\n * @returns\n * This object.\n */\n public gravatar(hash?: string, size?: number): this {\n let current = this.parse(ZUrlBuilder.UrlGravatar);\n current = hash ? current.append(hash) : current;\n current = size ? current.param('s', String(size)) : current;\n return current;\n }\n\n /**\n * Sets the url for a target video on YouTube.\n *\n * @param api -\n * The target api. If this is watch, then\n * it will be a target link to a youTube url.\n * If this is embed, then it will be a target\n * link that can be put into an iframe for\n * embedded youtube videos.\n * @param id -\n * The id of the video to watch.\n *\n * @returns\n * This object.\n */\n public youTube(api: ZYouTubeApi, id: string): this;\n\n /**\n * Sets the url to the base YouTube domain.\n *\n * @returns\n * This object.\n */\n public youTube(): this;\n\n /**\n * Sets the url target to something on YouTube.\n *\n * @param api -\n * The supported api.\n * @param id -\n * The id of the video. If api is set,\n * then this parameter is required.\n *\n * @returns\n * The url for YouTube. If you set the api and\n * id, then the url will be targeted to a specific video,\n * otherwise, the base domain url of YouTube will be returned.\n */\n public youTube(api?: ZYouTubeApi, id?: string) {\n let current = this.parse(ZUrlBuilder.UrlYouTube);\n current = api ? current.path(`${api}/${id}`) : current;\n\n // The watch api is a little bizarre that they don't actually\n // use the same format as their other apis. So we will handle this here.\n if (api === ZYouTubeApi.Watch) {\n current = current.path(api).param('v', id!);\n }\n\n return current;\n }\n\n /**\n * Sets the protocol.\n *\n * @param protocol -\n * The protocol.\n *\n * @returns\n * This object.\n */\n public protocol(protocol: string): this {\n this._url.protocol = protocol;\n return this;\n }\n\n /**\n * Sets the user name.\n *\n * Used for things like ssh and ftp.\n *\n * @param user -\n * The username\n *\n * @returns\n * This object.\n */\n public username(user: string | undefined): this {\n this._url.username = user;\n return this;\n }\n\n /**\n * Sets the password.\n *\n * This is only valid if the username is set.\n *\n * @param pwd -\n * The user password.\n *\n * @returns\n * This object.\n */\n public password(pwd: string | undefined): this {\n this._url.password = pwd;\n return this;\n }\n\n /**\n * Sets the host name.\n *\n * This sets the entire hostname as the root domain. This\n * will blow away any subdomains added, so it's best to\n * call this method first.\n *\n * @param host -\n * The hostname.\n *\n * @returns\n * This object.\n */\n public hostname(host: string): this {\n this._url.hostname = host;\n return this;\n }\n\n /**\n * Adds a subdomain in front of the hostname.\n *\n * If a hostname was never set, then domain becomes the hostname.\n *\n * @param domain -\n * The domain to append.\n *\n * @returns\n * This object.\n */\n public subdomain(domain: string): this {\n this._url.hostname = this._url.hostname ? `${domain}.${this._url.hostname}` : domain;\n return this;\n }\n\n /**\n * Removes a subdomain from the current domain.\n *\n * @returns\n * This object.\n */\n public popSubdomain(): this {\n const parts = this._url.hostname.split('.');\n parts.splice(0, 1);\n this._url.hostname = parts.join('.');\n return this;\n }\n\n /**\n * Sets the port.\n *\n * @param port -\n * The port.\n *\n * @returns\n * This object.\n */\n public port(port: number | undefined): this {\n this._url.port = port;\n return this;\n }\n\n /**\n * Removes all existing path segments and restarts the path.\n *\n * @param path -\n * The starting path.\n *\n * @returns\n * This object.\n */\n public path(path: string): this {\n this._url.path = [path];\n return this;\n }\n\n /**\n * Appends a path segment.\n *\n * @param path -\n * The segment to append.\n *\n * @returns\n * This object.\n */\n public append(path: string): this {\n this._url.path.push(path);\n return this;\n }\n\n /**\n * Sets the hash section.\n *\n * @param hash -\n * The hash section.\n *\n * @returns\n * This object.\n */\n public hash(hash: string | undefined): this {\n this._url.hash = hash;\n return this;\n }\n\n /**\n * Adds a search parameter.\n *\n * This version assumes that value is not null.\n *\n * @param key -\n * The parameter key.\n * @param val -\n * The parameter value.\n *\n * @returns\n * This object.\n */\n public param(key: string, val: string): this {\n this._url.params.push({ key, val });\n return this;\n }\n\n /**\n * Removes all duplicate params and adds one with the key to the value.\n *\n * @param key -\n * The parameter key that can have only one.\n * @param val -\n * The parameter value. If this is falsy, then\n * the key is deleted.\n */\n public onlyParam(key: string, val?: string): this {\n this._url.params = this._url.params.filter((p) => p.key !== key);\n return val ? this.param(key, val) : this;\n }\n\n /**\n * Adds a page param.\n *\n * @param page -\n * The page param to add. If this null, undefined,\n * or less than 1, then any page param is deleted.\n *\n * @returns\n * This object.\n */\n public page(page?: number | null): this {\n return this.onlyParam('page', page == null || page < 1 ? undefined : String(page));\n }\n\n /**\n * Adds a size param.\n *\n * @param size -\n * The size param to add. If this is null, undefined,\n * or less than 0, then any size param is deleted.\n *\n * @returns\n * This object.\n */\n public size(size?: number | null): this {\n return this.onlyParam('size', size == null || size < 0 ? undefined : String(size));\n }\n\n /**\n * Adds a search param.\n *\n * @param search -\n * The search param to add. If this is null, undefined,\n * or empty, then any search param is deleted.\n *\n * @returns\n * This object.\n */\n public search(search?: string | null): this {\n return this.onlyParam('search', search || undefined);\n }\n\n /**\n * Adds a filter param.\n *\n * @param filter -\n * The filter param to add. If this is null, undefined,\n * or empty, then any filter param is deleted.\n *\n * @returns\n * This object.\n */\n public filter(filter?: string | null): this {\n return this.onlyParam('filter', filter || undefined);\n }\n\n /**\n * Adds a sort param.\n *\n * @param sort -\n * The sort param to add. If this is null, undefined,\n * or empty, then any filter param is deleted.\n *\n * @returns\n * This object.\n */\n public sort(sort?: string | null): this {\n return this.onlyParam('sort', sort || undefined);\n }\n\n /**\n * Builds the url string and returns it.\n *\n * @returns\n * The url string.\n */\n public build(): string {\n const search = this._url.params.map((param) => `${param.key}=${encodeURIComponent(param.val)}`).join('&');\n const user = trim(this._url.username);\n const password = trim(this._url.password);\n let protocol = trim(this._url.protocol);\n let host = trim(this._url.hostname);\n let port = String(this._url.port);\n let hash = trim(this._url.hash);\n let path = this._url.path.map((segment) => trim(segment, '/')).join('/');\n let credentials = '';\n\n protocol = trimEnd(protocol, '/:');\n host = trim(host, '/');\n hash = trimStart(hash, '#');\n path = trim(path, '/');\n\n if (ZUrlBuilder.defaults(protocol, port)) {\n port = '';\n } else {\n port = `:${port}`;\n }\n\n if (user) {\n credentials = password ? `${user}:${password}@` : `${user}@`;\n }\n\n let url = `${protocol}://${credentials}${host}${port}`;\n\n if (path) {\n url = `${url}/${path}`;\n }\n\n if (search) {\n url = `${url}/?${search}`;\n }\n\n if (hash) {\n url = `${url}#${hash}`;\n }\n\n return url;\n }\n\n /**\n * Gets the current information about the uri being built.\n *\n * @returns The current uri information.\n */\n public info(): IZUrlInfo {\n return JSON.parse(JSON.stringify(this._url));\n }\n}\n"],"names":["ZMimeTypeApplication","ZMimeTypeImage","ZMimeTypeText","Buffer","ZYouTubeApi"],"mappings":";;;;;;;;;AAKY,IAAA,yCAAAA,0BAAL;AAILA,wBAAA,MAAO,IAAA;AAOPA,wBAAA,aAAc,IAAA;AAKdA,wBAAA,KAAM,IAAA;AAhBIA,SAAAA;AAAA,GAAA,wBAAA,CAAA,CAAA;ACAA,IAAA,mCAAAC,oBAAL;AAKLA,kBAAA,MAAO,IAAA;AAUPA,kBAAA,MAAO,IAAA;AAMPA,kBAAA,KAAM,IAAA;AAONA,kBAAA,MAAO,IAAA;AAOPA,kBAAA,KAAM,IAAA;AAMNA,kBAAA,KAAM,IAAA;AAQNA,kBAAA,MAAO,IAAA;AAjDGA,SAAAA;AAAA,GAAA,kBAAA,CAAA,CAAA;ACAA,IAAA,kCAAAC,mBAAL;AAKLA,iBAAA,KAAM,IAAA;AAKNA,iBAAA,KAAM,IAAA;AAKNA,iBAAA,YAAa,IAAA;AAMbA,iBAAA,MAAO,IAAA;AAKPA,iBAAA,YAAa,IAAA;AAKbA,iBAAA,OAAQ,IAAA;AAQRA,iBAAA,KAAM,IAAA;AAvCIA,S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G,GAAG,IAAI,IAAI;AAAA,IACtB;AAEA,QAAI,QAAQ;AACJ,YAAA,GAAG,GAAG,KAAK,MAAM;AAAA,IACzB;AAEA,QAAI,MAAM;AACF,YAAA,GAAG,GAAG,IAAI,IAAI;AAAA,IACtB;AAEO,WAAA;AAAA,EACT;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOO,OAAkB;AACvB,WAAO,KAAK,MAAM,KAAK,UAAU,KAAK,IAAI,CAAC;AAAA,EAC7C;AACF;AAAA;AAAA;AAAA;AAhhBE,cAJW,cAIG,eAAc;AAAA;AAAA;AAAA;AAAA;AAAA;AAO5B,cAXW,cAWG,cAAa;AAAA;AAAA;AAAA;AAK3B,cAhBW,cAgBG,iBAAgB;AAAA,EAC5B,MAAM;AAAA,EACN,OAAO;AAAA,EACP,KAAK;AAAA,EACL,MAAM;AAAA,EACN,KAAK;AAAA,EACL,MAAM;AAAA,EACN,KAAK;AAAA;AAvBF,IAAM,cAAN;"}
|
package/dist/url/url.d.mts
CHANGED
|
@@ -51,6 +51,8 @@ export declare class ZUrlBuilder {
|
|
|
51
51
|
page(page?: number | null): this;
|
|
52
52
|
size(size?: number | null): this;
|
|
53
53
|
search(search?: string | null): this;
|
|
54
|
+
filter(filter?: string | null): this;
|
|
55
|
+
sort(sort?: string | null): this;
|
|
54
56
|
build(): string;
|
|
55
57
|
info(): IZUrlInfo;
|
|
56
58
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zthun/webigail-url",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.4.0",
|
|
4
4
|
"description": "Url parsing and building.",
|
|
5
5
|
"author": "Anthony Bonta",
|
|
6
6
|
"license": "MIT",
|
|
@@ -25,16 +25,17 @@
|
|
|
25
25
|
"access": "public"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
|
-
"vite": "^5.
|
|
28
|
+
"vite": "^5.1.1",
|
|
29
29
|
"vitest": "^1.2.2"
|
|
30
30
|
},
|
|
31
31
|
"files": [
|
|
32
32
|
"dist"
|
|
33
33
|
],
|
|
34
34
|
"dependencies": {
|
|
35
|
+
"buffer": "^6.0.3",
|
|
35
36
|
"lodash-es": "^4.17.21",
|
|
36
37
|
"url-parse": "^1.5.10"
|
|
37
38
|
},
|
|
38
39
|
"sideEffects": false,
|
|
39
|
-
"gitHead": "
|
|
40
|
+
"gitHead": "024fcb71bea75232c1ed8f2ae5cd78a5c8ff20fd"
|
|
40
41
|
}
|