cizgile 0.2.0 → 0.3.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 +53 -33
- package/dist/index.d.mts +20 -12
- package/dist/index.mjs +124 -53
- package/dist/shared/{locales-latin-Bm94HAeL.mjs → registry-_m94akct.mjs} +154 -13
- package/dist/shared/{types-DbyhfPRc.d.mts → types-B3EVWvDh.d.mts} +1 -1
- package/dist/transliterate.d.mts +64 -2
- package/dist/transliterate.mjs +7344 -11
- package/dist/uri.d.mts +68 -17
- package/dist/uri.mjs +399 -236
- package/package.json +3 -2
package/dist/uri.d.mts
CHANGED
|
@@ -37,22 +37,19 @@ interface NormalizeUriOptions {
|
|
|
37
37
|
readonly schemeBased?: boolean;
|
|
38
38
|
/** Redacts credentials, for logs; `"keep"` by default. */
|
|
39
39
|
readonly userinfo?: "keep" | "strip-password" | "strip";
|
|
40
|
+
/** What to do with a trailing slash on a path longer than `/`; `"keep"` by default. */
|
|
41
|
+
readonly trailingSlash?: "keep" | "add" | "remove";
|
|
42
|
+
/** Drop a `?` with nothing after it; `"keep"` by default. */
|
|
43
|
+
readonly emptyQuery?: "keep" | "remove";
|
|
44
|
+
/** Drop a `#` with nothing after it; `"keep"` by default. */
|
|
45
|
+
readonly emptyFragment?: "keep" | "remove";
|
|
46
|
+
/** Convert a registered-name host to its `xn--` form or back to Unicode; `"keep"` by default. */
|
|
47
|
+
readonly host?: "keep" | "idna" | "unicode";
|
|
48
|
+
/** Throw a `TypeError` on a host or port the RFC 3986 grammar rejects instead of passing it through. */
|
|
49
|
+
readonly strict?: boolean;
|
|
40
50
|
}
|
|
41
51
|
/** Default ports of the common schemes, used by `normalizeUri` and `equivalentUris`. */
|
|
42
52
|
export declare const DEFAULT_PORTS: Readonly<Record<string, number>>;
|
|
43
|
-
/** The parts of an RFC 3986 `authority`. */
|
|
44
|
-
interface AuthorityComponents {
|
|
45
|
-
/** Without the trailing `@`. */
|
|
46
|
-
userinfo?: string;
|
|
47
|
-
/** As written, brackets included for IP literals. */
|
|
48
|
-
host: string;
|
|
49
|
-
/** Digits only, without the colon; `""` when the colon was present but empty. */
|
|
50
|
-
port?: string;
|
|
51
|
-
}
|
|
52
|
-
/** Splits an authority into userinfo, host and port. */
|
|
53
|
-
export declare function parseAuthority(authority: string): AuthorityComponents;
|
|
54
|
-
/** Recomposes an authority from its parts. */
|
|
55
|
-
export declare function serializeAuthority(components: AuthorityComponents): string;
|
|
56
53
|
/** RFC 3986 section 6.2 syntax-based and scheme-based normalisation: case, percent-encoding, dot segments, default ports, empty path. */
|
|
57
54
|
export declare function normalizeUri(input: string, options?: NormalizeUriOptions): string;
|
|
58
55
|
//#endregion
|
|
@@ -103,9 +100,35 @@ export declare function encodeFragment(fragment: string): string;
|
|
|
103
100
|
export declare function encodeForm(value: string): string;
|
|
104
101
|
//#endregion
|
|
105
102
|
//#region src/uri/extract.d.ts
|
|
103
|
+
/** A URI found in prose by `findUris`, with its offsets in the text. */
|
|
104
|
+
interface FoundUri {
|
|
105
|
+
readonly uri: string;
|
|
106
|
+
readonly start: number;
|
|
107
|
+
readonly end: number;
|
|
108
|
+
}
|
|
109
|
+
/** Finds the URIs in ordinary text: anything with `scheme://`, a `www.` host, or a `mailto:`, `tel:`, `urn:`, `data:` style scheme, ending at whitespace or a quote and trimmed of trailing punctuation the way `extractUri` does. */
|
|
110
|
+
export declare function findUris(text: string): FoundUri[];
|
|
106
111
|
/** RFC 3986 Appendix C: recovers a URI from text that wraps it in `<>`, quotes or brackets, prefixes it with `URL:`, breaks it across lines or ends it with punctuation. Markdown links and `href`/`src` attributes yield their URL. */
|
|
107
112
|
export declare function extractUri(text: string): string;
|
|
108
113
|
//#endregion
|
|
114
|
+
//#region src/uri/helpers.d.ts
|
|
115
|
+
/** RFC 6454 origin of a URI: lowercase `scheme://host` plus the port unless it is the scheme's default. `undefined` when there is no scheme or no authority. */
|
|
116
|
+
export declare function getOrigin(uri: string): string | undefined;
|
|
117
|
+
/** Whether two URIs share an RFC 6454 origin. Two URIs without an origin never match. */
|
|
118
|
+
export declare function isSameOrigin(a: string, b: string): boolean;
|
|
119
|
+
/** The URI without its fragment. */
|
|
120
|
+
export declare function stripFragment(uri: string): string;
|
|
121
|
+
/** A query parameter as a decoded `[name, value]` pair; a bare name has the value `""`. */
|
|
122
|
+
type QueryPair = readonly [string, string];
|
|
123
|
+
/** Decodes an `application/x-www-form-urlencoded` query (`a=1&b=2`, `+` as space) into pairs in order; a leading `?` is ignored. */
|
|
124
|
+
export declare function parseQuery(query: string): QueryPair[];
|
|
125
|
+
/** Encodes pairs as an `application/x-www-form-urlencoded` query without the leading `?`. */
|
|
126
|
+
export declare function stringifyQuery(pairs: Iterable<QueryPair>): string;
|
|
127
|
+
/** The URI with its query parameters sorted by name, then value, byte-wise on the encoded text; parameters are otherwise left as written. */
|
|
128
|
+
export declare function sortQuery(uri: string): string;
|
|
129
|
+
/** Joins path pieces with single slashes, keeps the first piece's leading slash and the last piece's trailing slash, and resolves `.` and `..` so the result never contains `//` or a dot segment. */
|
|
130
|
+
export declare function joinPaths(...pieces: readonly string[]): string;
|
|
131
|
+
//#endregion
|
|
109
132
|
//#region src/uri/host.d.ts
|
|
110
133
|
/** The three RFC 3986 section 3.2.2 host forms. */
|
|
111
134
|
type HostKind = "ip-literal" | "ipv4" | "reg-name";
|
|
@@ -120,6 +143,8 @@ interface ParsedHost {
|
|
|
120
143
|
export declare function isIPv4Address(text: string): boolean;
|
|
121
144
|
/** RFC 3986 `IPv6address`, all nine ABNF alternatives including the embedded IPv4 form. */
|
|
122
145
|
export declare function isIPv6Address(text: string): boolean;
|
|
146
|
+
/** RFC 5952 canonical text of an IPv6 address: lowercase, no leading zeros, the longest zero run as `::`, an embedded IPv4 tail kept. Anything that is not an IPv6 address is returned as is. */
|
|
147
|
+
export declare function normalizeIPv6Address(text: string): string;
|
|
123
148
|
/** RFC 3986 `IPvFuture`: `v` + hex + `.` + unreserved or sub-delims. */
|
|
124
149
|
export declare function isIPvFuture(text: string): boolean;
|
|
125
150
|
/** RFC 3986 `IP-literal`: an IPv6 address or IPvFuture in square brackets. */
|
|
@@ -173,11 +198,37 @@ interface UriComponents {
|
|
|
173
198
|
query?: string;
|
|
174
199
|
/** Without the leading `#`. */
|
|
175
200
|
fragment?: string;
|
|
201
|
+
/** The authority's userinfo; set by `parseUri(input, { authority: true })`, read by `serializeUri` when `authority` is absent. */
|
|
202
|
+
userinfo?: string;
|
|
203
|
+
/** The authority's host; set by `parseUri(input, { authority: true })`, read by `serializeUri` when `authority` is absent. */
|
|
204
|
+
host?: string;
|
|
205
|
+
/** The authority's port as written; set by `parseUri(input, { authority: true })`, read by `serializeUri` when `authority` is absent. */
|
|
206
|
+
port?: string;
|
|
207
|
+
/** The port as a number when it is in range; set by `parseUri(input, { authority: true })`. */
|
|
208
|
+
portNumber?: number;
|
|
176
209
|
}
|
|
177
|
-
/**
|
|
178
|
-
|
|
179
|
-
/**
|
|
210
|
+
/** Options for `parseUri`. */
|
|
211
|
+
interface ParseUriOptions {
|
|
212
|
+
/** Also split the authority into `userinfo`, `host`, `port` and `portNumber`. */
|
|
213
|
+
readonly authority?: boolean;
|
|
214
|
+
}
|
|
215
|
+
/** Splits a URI reference into its components with the RFC 3986 Appendix B regular expression; never throws. With `authority: true` the authority is split further. */
|
|
216
|
+
export declare function parseUri(input: string, options?: ParseUriOptions): UriComponents;
|
|
217
|
+
/** Recomposes components per RFC 3986 section 5.3, inserting `/.` or `./` where the grammar requires it. `authority` wins over `host`, `port` and `userinfo`. */
|
|
180
218
|
export declare function serializeUri(components: UriComponents): string;
|
|
219
|
+
/** The parts of an RFC 3986 `authority`. */
|
|
220
|
+
interface AuthorityComponents {
|
|
221
|
+
/** Without the trailing `@`. */
|
|
222
|
+
userinfo?: string;
|
|
223
|
+
/** As written, brackets included for IP literals. */
|
|
224
|
+
host: string;
|
|
225
|
+
/** Digits only, without the colon; `""` when the colon was present but empty. */
|
|
226
|
+
port?: string;
|
|
227
|
+
}
|
|
228
|
+
/** Splits an authority into userinfo, host and port. */
|
|
229
|
+
export declare function parseAuthority(authority: string): AuthorityComponents;
|
|
230
|
+
/** Recomposes an authority from its parts. */
|
|
231
|
+
export declare function serializeAuthority(components: AuthorityComponents): string;
|
|
181
232
|
//#endregion
|
|
182
233
|
//#region src/uri/path.d.ts
|
|
183
234
|
/** RFC 3986 section 5.2.4, the two-buffer algorithm as written: resolves `.` and `..` segments. */
|
|
@@ -278,4 +329,4 @@ export declare function isIriReference(input: string): boolean;
|
|
|
278
329
|
/** Whether `input` is a valid RFC 3987 `IRI`. */
|
|
279
330
|
export declare function isIri(input: string): boolean;
|
|
280
331
|
//#endregion
|
|
281
|
-
export type { AuthorityComponents, EncodePathOptions, EncodePathSegmentOptions, EncodeSet, EncodeSetName, EquivalenceLevel, EquivalentUrisOptions, HostKind, IriToUriOptions, NormalizePathOptions, NormalizeUriOptions, ParsedHost, PathForm, PercentDecodeOptions, ReferenceClassification, ResolveUriOptions, SameDocumentOptions, UriComponents, ValidateOptions };
|
|
332
|
+
export type { AuthorityComponents, EncodePathOptions, EncodePathSegmentOptions, EncodeSet, EncodeSetName, EquivalenceLevel, EquivalentUrisOptions, FoundUri, HostKind, IriToUriOptions, NormalizePathOptions, NormalizeUriOptions, ParseUriOptions, ParsedHost, PathForm, PercentDecodeOptions, QueryPair, ReferenceClassification, ResolveUriOptions, SameDocumentOptions, UriComponents, ValidateOptions };
|