1 | // Type definitions for valid-url v1.0.9
|
2 | // Project: https://github.com/ogt/valid-url
|
3 | // Definitions by: Steve Hipwell <https://github.com/stevehipwell>
|
4 | // Gabriel Cangussu <https://github.com/gcangussu>
|
5 | // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
6 |
|
7 | /**
|
8 | * Is the value a well-formed uri?
|
9 | * Returns the untainted URI if the test value appears to be well-formed. Note that you may really want one of the more practical methods like is_http_uri or is_https_uri, since the URI standard (RFC 3986) allows a lot of things you probably don't want.
|
10 | * @param value - The potential URI to test.
|
11 | * @returns The untainted RFC 3986 URI on success, undefined on failure.
|
12 | */
|
13 | export function isUri(value: string): string | undefined;
|
14 |
|
15 | /**
|
16 | * Is the value a well-formed HTTP uri?
|
17 | * Specialized version of isUri() that only likes http:// urls. As a result, it can also do a much more thorough job validating. Also, unlike isUri() it is more concerned with only allowing real-world URIs through. Things like relative hostnames are allowed by the standards, but probably aren't wise. Conversely, null paths aren't allowed per RFC 2616 (should be '/' instead), but are allowed by this function.
|
18 | *
|
19 | * This function only works for fully-qualified URIs. /bob.html won't work. See RFC 3986 for the appropriate method to turn a relative URI into an absolute one given its context.
|
20 | *
|
21 | * Note that you probably want to either call this in combo with is_https_uri().
|
22 | * i.e. if(isHttpUri(uri) || isHttpsUri(uri)) console.log('Good');
|
23 | * or use the convenience method isWebUri which is equivalent.
|
24 | * @param value - The potential URI to test.
|
25 | * @returns The untainted RFC 3986 URI on success, undefined on failure.
|
26 | */
|
27 | export function isHttpUri(value: string): string | undefined;
|
28 |
|
29 |
|
30 | /**
|
31 | * Is the value a well-formed HTTPS uri?
|
32 | *See is_http_uri() for details. This version only likes the https URI scheme. Otherwise it's identical to is_http_uri().
|
33 | * @param value - The potential URI to test.
|
34 | * @returns The untainted RFC 3986 URI on success, undefined on failure.
|
35 | */
|
36 | export function isHttpsUri(value: string): string | undefined;
|
37 |
|
38 | /**
|
39 | * Is the value a well-formed HTTP or HTTPS uri?
|
40 | * This is just a convenience method that combines isHttpUri and isHttpsUri to accept most common real-world URLs.
|
41 | * @param value - The potential URI to test.
|
42 | * @returns The untainted RFC 3986 URI on success, undefined on failure.
|
43 | */
|
44 | export function isWebUri(value: string): string | undefined;
|