@zthun/webigail-url 2.4.1 → 3.0.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/README.md CHANGED
@@ -1,7 +1,8 @@
1
1
  # Webigail URL
2
2
 
3
- It's easy to make mistakes when making REST invocations and public API calls. Webigail solves this by using the builder
4
- pattern to construct a full URL given different parts of a URI.
3
+ It's easy to make mistakes when making REST invocations and public API calls.
4
+ Webigail solves this by using the builder pattern to construct a full URL given
5
+ different parts of a URI.
5
6
 
6
7
  ## Build Status
7
8
 
@@ -19,9 +20,13 @@ yarn add @zthun/webigail-url
19
20
  ```
20
21
 
21
22
  ```ts
22
- import { ZUrlBuilder } from '@zthun/webigail-url';
23
+ import { ZUrlBuilder } from "@zthun/webigail-url";
23
24
 
24
- const url = new ZUrlBuilder().protocol('https').hostname('zthunworks.com').subdomain('webigail').build();
25
+ const url = new ZUrlBuilder()
26
+ .protocol("https")
27
+ .hostname("zthunworks.com")
28
+ .subdomain("webigail")
29
+ .build();
25
30
 
26
31
  // Outputs https://webigail.zthunworks.com
27
32
  console.log(url);
@@ -30,19 +35,23 @@ console.log(url);
30
35
  There are also some utility functions for common use cases.
31
36
 
32
37
  ```ts
33
- import { ZUrlBuilder } from '@zthun/webigail-url';
38
+ import { ZUrlBuilder } from "@zthun/webigail-url";
34
39
 
35
40
  // Note: Browser only unless you're using jsdom in node. Outputs the current
36
41
  // browser location with /api appended to it.
37
- const locationUrl = new ZUrlBuilder().location(location).path('/api').build();
42
+ const locationUrl = new ZUrlBuilder().location(location).path("/api").build();
38
43
  console.log(url);
39
44
 
40
45
  // Url for a persons gravatar if one exists.
41
- const avatar = new ZUrlBuilder().gravatar(md5('john-doe@gmail.com'), 256).build();
46
+ const avatar = new ZUrlBuilder()
47
+ .gravatar(md5("john-doe@gmail.com"), 256)
48
+ .build();
42
49
  console.log(avatar);
43
50
 
44
51
  // Outputs the existing pieces of the url.
45
- const existingInfo = new ZUrlBuilder().parse('https://webigail.zthunworks.com/api/path?filter=hello').info();
52
+ const existingInfo = new ZUrlBuilder()
53
+ .parse("https://webigail.zthunworks.com/api/path?filter=hello")
54
+ .info();
46
55
  console.log(existingInfo);
47
56
  ```
48
57
 
@@ -51,10 +60,14 @@ console.log(existingInfo);
51
60
  Webigail also supports building and parsing data urls as well.
52
61
 
53
62
  ```ts
54
- import { ZDataUrlBuilder, ZMimeTypeApplication } from '@zthun/webigail-url';
63
+ import { ZDataUrlBuilder, ZMimeTypeApplication } from "@zthun/webigail-url";
55
64
 
56
- const raw = require('my-data.json');
65
+ const raw = require("my-data.json");
57
66
  const mimeType = ZMimeTypeApplication.JSON;
58
- const url = new ZDataUrlBuilder().mimeType(mimeType).buffer(Buffer.from(raw)).encode('base64').build();
67
+ const url = new ZDataUrlBuilder()
68
+ .mimeType(mimeType)
69
+ .buffer(Buffer.from(raw))
70
+ .encode("base64")
71
+ .build();
59
72
  console.log(url);
60
73
  ```
@@ -1,17 +1,15 @@
1
- import { Buffer } from 'buffer';
2
-
3
1
  export interface IZDataUrlInfo {
4
2
  mimeType: string;
5
- encoding: 'base64' | 'utf8';
6
- buffer: Buffer;
3
+ encoding: "base64" | "utf8";
4
+ buffer: Uint8Array;
7
5
  }
8
6
  export declare class ZDataUrlBuilder {
9
7
  private _data;
10
8
  constructor();
11
9
  parse(url: string): this;
12
10
  mimeType(type: string): this;
13
- buffer(data: Buffer | string): this;
14
- encode(encoding: 'base64' | 'utf8'): this;
11
+ buffer(data: string | Uint8Array): this;
12
+ encode(encoding: "base64" | "utf8"): this;
15
13
  build(): string;
16
14
  info(): IZDataUrlInfo;
17
15
  }
package/dist/index.cjs CHANGED
@@ -3,7 +3,6 @@ var __defProp = Object.defineProperty;
3
3
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
4
4
  var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
5
5
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
6
- const buffer = require("buffer");
7
6
  const lodashEs = require("lodash-es");
8
7
  const URLParse = require("url-parse");
9
8
  var ZMimeTypeApplication = /* @__PURE__ */ ((ZMimeTypeApplication2) => {
@@ -50,7 +49,7 @@ class ZDataUrlBuilder {
50
49
  this._data = {
51
50
  mimeType: "",
52
51
  encoding: "utf8",
53
- buffer: buffer.Buffer.from("")
52
+ buffer: new Uint8Array([])
54
53
  };
55
54
  }
56
55
  /**
@@ -66,7 +65,7 @@ class ZDataUrlBuilder {
66
65
  this._data = {
67
66
  mimeType: "",
68
67
  encoding: "utf8",
69
- buffer: buffer.Buffer.from("")
68
+ buffer: new Uint8Array([])
70
69
  };
71
70
  if (!url.startsWith("data:")) {
72
71
  return this;
@@ -89,8 +88,17 @@ class ZDataUrlBuilder {
89
88
  }
90
89
  type = [type, ...params].join(";");
91
90
  this._data.mimeType = type;
92
- const body = bodyParts.join("%2C");
93
- this._data.buffer = isBase64 ? buffer.Buffer.from(body, "base64") : buffer.Buffer.from(decodeURIComponent(body));
91
+ let body = bodyParts.join("%2C");
92
+ if (isBase64) {
93
+ try {
94
+ body = atob(body);
95
+ } catch {
96
+ body = "";
97
+ }
98
+ } else {
99
+ body = decodeURIComponent(body);
100
+ }
101
+ this._data.buffer = new TextEncoder().encode(body);
94
102
  return this;
95
103
  }
96
104
  /**
@@ -116,7 +124,7 @@ class ZDataUrlBuilder {
116
124
  * This object.
117
125
  */
118
126
  buffer(data) {
119
- this._data.buffer = typeof data === "string" ? buffer.Buffer.from(data) : data;
127
+ this._data.buffer = typeof data === "string" ? new TextEncoder().encode(data) : data;
120
128
  return this;
121
129
  }
122
130
  /**
@@ -143,11 +151,14 @@ class ZDataUrlBuilder {
143
151
  build() {
144
152
  const protocol = "data";
145
153
  const modifier = this._data.encoding === "base64" ? ";base64" : "";
146
- let raw = this._data.buffer.toString(this._data.encoding);
154
+ let raw = new TextDecoder("utf8").decode(this._data.buffer);
147
155
  if (this._data.encoding === "utf8") {
148
156
  raw = encodeURIComponent(raw);
149
157
  raw = raw.split("!").join("%21");
150
158
  }
159
+ if (this._data.encoding === "base64") {
160
+ raw = btoa(raw);
161
+ }
151
162
  return `${protocol}:${this._data.mimeType}${modifier},${raw}`;
152
163
  }
153
164
  /**
@@ -272,7 +283,9 @@ const _ZUrlBuilder = class _ZUrlBuilder {
272
283
  parse(url) {
273
284
  const current = new URLParse(url, true);
274
285
  this.protocol(current.protocol).username(current.username).password(current.password).hostname(current.hostname).hash(current.hash).path(current.pathname).port(current.port ? +current.port : void 0);
275
- Object.keys(current.query).forEach((key) => this.param(key, current.query[key]));
286
+ Object.keys(current.query).forEach(
287
+ (key) => this.param(key, current.query[key])
288
+ );
276
289
  return this;
277
290
  }
278
291
  /**
@@ -494,7 +507,10 @@ const _ZUrlBuilder = class _ZUrlBuilder {
494
507
  * This object.
495
508
  */
496
509
  page(page) {
497
- return this.onlyParam("page", page == null || page < 1 ? void 0 : String(page));
510
+ return this.onlyParam(
511
+ "page",
512
+ page == null || page < 1 ? void 0 : String(page)
513
+ );
498
514
  }
499
515
  /**
500
516
  * Adds a size param.
@@ -507,7 +523,10 @@ const _ZUrlBuilder = class _ZUrlBuilder {
507
523
  * This object.
508
524
  */
509
525
  size(size) {
510
- return this.onlyParam("size", size == null || size < 0 ? void 0 : String(size));
526
+ return this.onlyParam(
527
+ "size",
528
+ size == null || size < 0 ? void 0 : String(size)
529
+ );
511
530
  }
512
531
  /**
513
532
  * Adds a search param.
@@ -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 || 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,CAAC;AAAA,EAC5C,GAAGA,eAAM,OAAO,OAAO,aAAa,CAAC;AAAA,EACrC,GAAGA,eAAM,OAAO,OAAO,cAAc,CAAC;AACxC,CAAC;ACWM,MAAM,gBAAgB;AAAA;AAAA;AAAA;AAAA,EASpB,cAAc;AALb;AAAA;AAAA;AAAA;AAMN,SAAK,QAAQ;AAAA,MAC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,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;;;;;;;;"}
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 { 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: Uint8Array;\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: new Uint8Array([]),\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: new Uint8Array([]),\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 let body = bodyParts.join(\"%2C\");\n\n if (isBase64) {\n try {\n body = atob(body);\n } catch {\n body = \"\";\n }\n } else {\n body = decodeURIComponent(body);\n }\n this._data.buffer = new TextEncoder().encode(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: string | Uint8Array): this {\n this._data.buffer =\n typeof data === \"string\" ? new TextEncoder().encode(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 = new TextDecoder(\"utf8\").decode(this._data.buffer);\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 if (this._data.encoding === \"base64\") {\n raw = btoa(raw);\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)\n .hostname(loc.hostname)\n .hash(loc.hash)\n .path(loc.pathname)\n .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\n .map((pair) => pair.split(\"=\"))\n .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) =>\n this.param(key, current.query[key] as string),\n );\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\n ? `${domain}.${this._url.hostname}`\n : 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(\n \"page\",\n page == null || page < 1 ? undefined : String(page),\n );\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(\n \"size\",\n size == null || size < 0 ? undefined : String(size),\n );\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\n .map((param) => `${param.key}=${encodeURIComponent(param.val)}`)\n .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","last","ZYouTubeApi","trim","trimEnd","trimStart"],"mappings":";;;;;;;AAKY,IAAA,yCAAAA,0BAAL;AAILA,wBAAA,MAAO,IAAA;AAOPA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c;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
@@ -1,7 +1,6 @@
1
1
  var __defProp = Object.defineProperty;
2
2
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
3
  var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
4
- import { Buffer as Buffer2 } from "buffer";
5
4
  import { keyBy, last, trim, trimEnd, trimStart } from "lodash-es";
6
5
  import URLParse from "url-parse";
7
6
  var ZMimeTypeApplication = /* @__PURE__ */ ((ZMimeTypeApplication2) => {
@@ -48,7 +47,7 @@ class ZDataUrlBuilder {
48
47
  this._data = {
49
48
  mimeType: "",
50
49
  encoding: "utf8",
51
- buffer: Buffer2.from("")
50
+ buffer: new Uint8Array([])
52
51
  };
53
52
  }
54
53
  /**
@@ -64,7 +63,7 @@ class ZDataUrlBuilder {
64
63
  this._data = {
65
64
  mimeType: "",
66
65
  encoding: "utf8",
67
- buffer: Buffer2.from("")
66
+ buffer: new Uint8Array([])
68
67
  };
69
68
  if (!url.startsWith("data:")) {
70
69
  return this;
@@ -87,8 +86,17 @@ class ZDataUrlBuilder {
87
86
  }
88
87
  type = [type, ...params].join(";");
89
88
  this._data.mimeType = type;
90
- const body = bodyParts.join("%2C");
91
- this._data.buffer = isBase64 ? Buffer2.from(body, "base64") : Buffer2.from(decodeURIComponent(body));
89
+ let body = bodyParts.join("%2C");
90
+ if (isBase64) {
91
+ try {
92
+ body = atob(body);
93
+ } catch {
94
+ body = "";
95
+ }
96
+ } else {
97
+ body = decodeURIComponent(body);
98
+ }
99
+ this._data.buffer = new TextEncoder().encode(body);
92
100
  return this;
93
101
  }
94
102
  /**
@@ -114,7 +122,7 @@ class ZDataUrlBuilder {
114
122
  * This object.
115
123
  */
116
124
  buffer(data) {
117
- this._data.buffer = typeof data === "string" ? Buffer2.from(data) : data;
125
+ this._data.buffer = typeof data === "string" ? new TextEncoder().encode(data) : data;
118
126
  return this;
119
127
  }
120
128
  /**
@@ -141,11 +149,14 @@ class ZDataUrlBuilder {
141
149
  build() {
142
150
  const protocol = "data";
143
151
  const modifier = this._data.encoding === "base64" ? ";base64" : "";
144
- let raw = this._data.buffer.toString(this._data.encoding);
152
+ let raw = new TextDecoder("utf8").decode(this._data.buffer);
145
153
  if (this._data.encoding === "utf8") {
146
154
  raw = encodeURIComponent(raw);
147
155
  raw = raw.split("!").join("%21");
148
156
  }
157
+ if (this._data.encoding === "base64") {
158
+ raw = btoa(raw);
159
+ }
149
160
  return `${protocol}:${this._data.mimeType}${modifier},${raw}`;
150
161
  }
151
162
  /**
@@ -270,7 +281,9 @@ const _ZUrlBuilder = class _ZUrlBuilder {
270
281
  parse(url) {
271
282
  const current = new URLParse(url, true);
272
283
  this.protocol(current.protocol).username(current.username).password(current.password).hostname(current.hostname).hash(current.hash).path(current.pathname).port(current.port ? +current.port : void 0);
273
- Object.keys(current.query).forEach((key) => this.param(key, current.query[key]));
284
+ Object.keys(current.query).forEach(
285
+ (key) => this.param(key, current.query[key])
286
+ );
274
287
  return this;
275
288
  }
276
289
  /**
@@ -492,7 +505,10 @@ const _ZUrlBuilder = class _ZUrlBuilder {
492
505
  * This object.
493
506
  */
494
507
  page(page) {
495
- return this.onlyParam("page", page == null || page < 1 ? void 0 : String(page));
508
+ return this.onlyParam(
509
+ "page",
510
+ page == null || page < 1 ? void 0 : String(page)
511
+ );
496
512
  }
497
513
  /**
498
514
  * Adds a size param.
@@ -505,7 +521,10 @@ const _ZUrlBuilder = class _ZUrlBuilder {
505
521
  * This object.
506
522
  */
507
523
  size(size) {
508
- return this.onlyParam("size", size == null || size < 0 ? void 0 : String(size));
524
+ return this.onlyParam(
525
+ "size",
526
+ size == null || size < 0 ? void 0 : String(size)
527
+ );
509
528
  }
510
529
  /**
511
530
  * Adds a search param.
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 || 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;AAK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W,GAAG,IAAI,GAAG,IAAI;AAEpD,QAAI,MAAM;AACF,YAAA,GAAG,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;"}
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 { 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: Uint8Array;\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: new Uint8Array([]),\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: new Uint8Array([]),\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 let body = bodyParts.join(\"%2C\");\n\n if (isBase64) {\n try {\n body = atob(body);\n } catch {\n body = \"\";\n }\n } else {\n body = decodeURIComponent(body);\n }\n this._data.buffer = new TextEncoder().encode(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: string | Uint8Array): this {\n this._data.buffer =\n typeof data === \"string\" ? new TextEncoder().encode(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 = new TextDecoder(\"utf8\").decode(this._data.buffer);\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 if (this._data.encoding === \"base64\") {\n raw = btoa(raw);\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)\n .hostname(loc.hostname)\n .hash(loc.hash)\n .path(loc.pathname)\n .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\n .map((pair) => pair.split(\"=\"))\n .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) =>\n this.param(key, current.query[key] as string),\n );\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\n ? `${domain}.${this._url.hostname}`\n : 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(\n \"page\",\n page == null || page < 1 ? undefined : String(page),\n );\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(\n \"size\",\n size == null || size < 0 ? undefined : String(size),\n );\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\n .map((param) => `${param.key}=${encodeURIComponent(param.val)}`)\n .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","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;AAAA,EACrC,GAAG,MAAM,OAAO,OAAO,cAAc,CAAC;AACxC,CAAC;ACUM,MAAM,gBAAgB;AAAA;AAAA;AAAA;AAAA,EASpB,cAAc;AALb;AAAA;AAAA;AAAA;AAMN,SAAK,QAAQ;AAAA,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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;AAliBE,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;"}
@@ -1,8 +1,7 @@
1
1
  import { ZMimeTypeApplication } from './mime-type-application.mjs';
2
2
  import { ZMimeTypeImage } from './mime-type-image.mjs';
3
3
  import { ZMimeTypeText } from './mime-type-text.mjs';
4
-
5
4
  export type ZMimeType = ZMimeTypeApplication | ZMimeTypeText | ZMimeTypeImage;
6
5
  export declare const ZSupportedMimeTypes: Readonly<{
7
- '': "text/plain;charset=ASCII";
6
+ "": "text/plain;charset=ASCII";
8
7
  }>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zthun/webigail-url",
3
- "version": "2.4.1",
3
+ "version": "3.0.0",
4
4
  "description": "Url parsing and building.",
5
5
  "author": "Anthony Bonta",
6
6
  "license": "MIT",
@@ -25,17 +25,16 @@
25
25
  "access": "public"
26
26
  },
27
27
  "devDependencies": {
28
- "vite": "^5.3.3",
29
- "vitest": "^2.0.2"
28
+ "vite": "^5.4.10",
29
+ "vitest": "^2.1.4"
30
30
  },
31
31
  "files": [
32
32
  "dist"
33
33
  ],
34
34
  "dependencies": {
35
- "buffer": "^6.0.3",
36
35
  "lodash-es": "^4.17.21",
37
36
  "url-parse": "^1.5.10"
38
37
  },
39
38
  "sideEffects": false,
40
- "gitHead": "fa93ec3ab3adcf1fe29030cb0d5552c8607954e9"
39
+ "gitHead": "217a1f8050b591818162a2307c7e441f879b976f"
41
40
  }