isAbsoluteURI

Test whether a value is an absolute URI.

Usage

var isAbsoluteURI = require( '@stdlib/assert/is-absolute-uri' );

isAbsoluteURI( value )

Tests whether a value is an absolute URI.

var bool = isAbsoluteURI( 'http://example.com' );
// returns true

bool = isAbsoluteURI( './beep/boop' );
// returns false

Notes

Examples

var isAbsoluteURI = require( '@stdlib/assert/is-absolute-uri' );

var bool = isAbsoluteURI( 'https://www.google.com/' );
// returns true

bool = isAbsoluteURI( 'https://www.google.com/search?q=node.js' );
// returns true

bool = isAbsoluteURI( 'https://www.google.com#footer' );
// returns true

bool = isAbsoluteURI( '/search?q=node.js' );
// returns false

bool = isAbsoluteURI( 'C:\\Users\\nodejs\\node.js' );
// returns false

bool = isAbsoluteURI( null );
// returns false

CLI

Usage

Usage: is-absolute-uri [options] [<uri>]

Options:

  -h,    --help                Print this message.
  -V,    --version             Print the package version.
         --split sep           Delimiter for stdin data. Default: '/\\r?\\n/'.

Examples

$ is-absolute-uri https://google.com
true

To use as a standard stream,

$ echo -n 'https://google.com' | is-absolute-uri
true

By default, when used as a standard stream, the implementation assumes newline-delimited data. To specify an alternative delimiter, set the split option.

$ echo -n 'https://google.com\tbeep' | is-absolute-uri --split '\t'
true
false
Did you find this page helpful?