@stdlib/assert-is-relative-uri
v0.2.2
Published
Test whether a value is a relative URI.
Downloads
34
Readme
isRelativeURI
Test whether a value is a relative URI.
Installation
npm install @stdlib/assert-is-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
- For more information regarding the URI scheme, see RFC 3986 and Wikipedia.
- On the distinction between URI, URL, and URN, see The Difference Between URLs and URIs.
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:[email protected]' );
// returns false
bool = isRelativeURI( null );
// returns false
See Also
@stdlib/assert-is-relative-uri-cli
: CLI package for use as a command-line utility.@stdlib/assert-is-uri
: test if a value is a URI.
Notice
This package is part of stdlib, a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more.
For more information on the project, filing bug reports and feature requests, and guidance on how to develop stdlib, see the main project repository.
Community
License
See LICENSE.
Copyright
Copyright © 2016-2024. The Stdlib Authors.