Options
All
  • Public
  • Public/Protected
  • All
Menu

External module "assert/is-uri/docs/types/index.d"

Index

Functions

Functions

Export assignment isURI

  • isURI(value: any): boolean
  • Tests if a value is a URI.

    Parameters

    • value: any

      value to test

    Returns boolean

    boolean indicating if a value is a URI

    Example

    var bool = isURI( 'http://google.com' );
    // returns true

    Example

    var bool = isURI( 'http://localhost/' );
    // returns true

    Example

    var bool = isURI( 'http://example.w3.org/path%20with%20spaces.html' );
    // returns true

    Example

    var bool = isURI( 'http://example.w3.org/%20' );
    // returns true

    Example

    var bool = isURI( 'ftp://ftp.is.co.za/rfc/rfc1808.txt' );
    // returns true

    Example

    var bool = isURI( 'ftp://ftp.is.co.za/../../../rfc/rfc1808.txt' );
    // returns true

    Example

    var bool = isURI( 'http://www.ietf.org/rfc/rfc2396.txt' );
    // returns true

    Example

    var bool = isURI( 'ldap://[2001:db8::7]/c=GB?objectClass?one' );
    // returns true

    Example

    var bool = isURI( 'mailto:John.Doe@example.com' );
    // returns true

    Example

    var bool = isURI( 'news:comp.infosystems.www.servers.unix' );
    // returns true

    Example

    var bool = isURI( 'tel:+1-816-555-1212' );
    // returns true

    Example

    var bool = isURI( 'telnet://192.0.2.16:80/' );
    // returns true

    Example

    var bool = isURI( 'urn:oasis:names:specification:docbook:dtd:xml:4.1.2' );
    // returns true

    Example

    // No scheme:
    var bool = isURI( '' );
    // returns false

    Example

    // No scheme:
    var bool = isURI( 'foo' );
    // returns false

    Example

    // No scheme:
    var bool = isURI( 'foo@bar' );
    // returns false

    Example

    // No scheme:
    var bool = isURI( '://foo/' );
    // returns false

    Example

    // Illegal characters:
    var bool = isURI( 'http://<foo>' );
    // returns false

    Example

    // Invalid path:
    var bool = isURI( 'http:////foo.html' );
    // returns false

    Example

    // Incomplete hex escapes...
    var bool = isURI( 'http://example.w3.org/%a' );
    // returns false

    Example

    var bool = isURI( 'http://example.w3.org/%a/foo' );
    // returns false

    Example

    var bool = isURI( 'http://example.w3.org/%at' );
    // returns false