isAbsolute(href) returns true when href starts with / or
carries a protocol (via hasProtocol). The
inverse is isRelative. Part of
pota/use/url.
| Argument | Type | Description |
|---|---|---|
href |
string |
The URL to test. |
Returns: true if the URL is absolute, false otherwise.
/-rooted and protocol-bearing URLs are absolute; bare and hash links
are not.
import { isAbsolute } from 'pota/use/url'
isAbsolute('/about') // true
isAbsolute('http://local/') // true
isAbsolute('about') // false
isAbsolute('#section') // false