toad-uri-js
Version:
A modern RFC 3986/3987 compliant, scheme extendable URI/IRI parsing/normalizing/resolving/serializing library for JavaScript.
69 lines (67 loc) • 2.82 kB
text/typescript
/**
* URI.js
*
* @fileoverview An RFC 3986 compliant, scheme extendable URI parsing/normalizing/resolving/serializing library for JavaScript.
* @author <a href="mailto:gary.court@gmail.com">Gary Court</a>
* @see http://github.com/garycourt/uri-js
*/
interface URIComponents {
scheme?: string;
userinfo?: string;
host?: string;
port?: number | string;
path?: string;
query?: string;
fragment?: string;
reference?: string;
error?: string;
}
interface URIOptions {
scheme?: string;
reference?: string;
tolerant?: boolean;
absolutePath?: boolean;
iri?: boolean;
unicodeSupport?: boolean;
domainHost?: boolean;
}
interface URISchemeHandler<Components extends URIComponents = URIComponents, Options extends URIOptions = URIOptions, ParentComponents extends URIComponents = URIComponents> {
scheme: string;
parse(components: ParentComponents, options: Options): Components;
serialize(components: Components, options: Options): ParentComponents;
unicodeSupport?: boolean;
domainHost?: boolean;
absolutePath?: boolean;
}
interface URIRegExps {
NOT_SCHEME: RegExp;
NOT_USERINFO: RegExp;
NOT_HOST: RegExp;
NOT_PATH: RegExp;
NOT_PATH_NOSCHEME: RegExp;
NOT_QUERY: RegExp;
NOT_FRAGMENT: RegExp;
ESCAPE: RegExp;
UNRESERVED: RegExp;
OTHER_CHARS: RegExp;
PCT_ENCODED: RegExp;
IPV4ADDRESS: RegExp;
IPV6ADDRESS: RegExp;
}
declare const SCHEMES: {
[scheme: string]: URISchemeHandler;
};
declare function pctEncChar(chr: string): string;
declare function pctDecChars(str: string): string;
declare function parse(uriString: string, options?: URIOptions): URIComponents;
declare function removeDotSegments(input: string): string;
declare function serialize(components: URIComponents, options?: URIOptions): string;
declare function resolveComponents(base: URIComponents, relative: URIComponents, options?: URIOptions, skipNormalization?: boolean): URIComponents;
declare function resolve(baseURI: string, relativeURI: string, options?: URIOptions): string;
declare function normalize(uri: string, options?: URIOptions): string;
declare function normalize(uri: URIComponents, options?: URIOptions): URIComponents;
declare function equal(uriA: string, uriB: string, options?: URIOptions): boolean;
declare function equal(uriA: URIComponents, uriB: URIComponents, options?: URIOptions): boolean;
declare function escapeComponent(str: string, options?: URIOptions): string;
declare function unescapeComponent(str: string, options?: URIOptions): string;
export { SCHEMES, type URIComponents, type URIOptions, type URIRegExps, type URISchemeHandler, equal, escapeComponent, normalize, parse, pctDecChars, pctEncChar, removeDotSegments, resolve, resolveComponents, serialize, unescapeComponent };