isRelativeURI

Test whether a value is a relative URI.

Usage

var isRelativeURI = require( '@stdlib/assert/is-relative-uri' );

isRelativeURI( value )

Tests whether a value is a relative URI.

var bool = isRelativeURI( 'foo/bar' );
// returns true

bool = isRelativeURI( 'https://example.com/' );
// returns false

Notes

Examples

var isRelativeURI = require( '@stdlib/assert/is-relative-uri' );

var bool = isRelativeURI( './foo.js' );
// returns true

bool = isRelativeURI( '/dashboard/admin' );
// returns true

bool = isRelativeURI( 'image.png' );
// returns true

bool = isRelativeURI( 'http://www.example.com/' );
// returns false

bool = isRelativeURI( 'https://www.example.com/' );
// returns false

bool = isRelativeURI( 'ftp://ftp.is.co.za/rfc/rfc1808.txt' );
// returns false

bool = isRelativeURI( 'data:text/plain;base64,SGVsbG8sIFdvcmxkIQ%3D%3D' );
// returns false

bool = isRelativeURI( 'mailto:beep@boop.com' );
// returns false

bool = isRelativeURI( null );
// returns false

CLI

Usage

Usage: is-relative-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-relative-uri google.com
true

To use as a standard stream,

$ echo -n 'https://google.com' | is-relative-uri
false

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'
false
true
Did you find this page helpful?