is-absolute-url
- Version 5.0.0
- Published
- 4.84 kB
- No dependencies
- MIT license
Install
npm i is-absolute-url
yarn add is-absolute-url
pnpm add is-absolute-url
Overview
Check if a URL is absolute
Index
Functions
Type Aliases
Functions
function isAbsoluteUrl
isAbsoluteUrl: (url: string, options?: Options) => boolean;
Check if a URL is absolute.
Parameter url
The URL to check.
Parameter options
Options to customize the behavior.
Example 1
import isAbsoluteUrl from 'is-absolute-url';isAbsoluteUrl('https://sindresorhus.com/foo/bar');//=> trueisAbsoluteUrl('//sindresorhus.com');//=> falseisAbsoluteUrl('foo/bar');//=> falseisAbsoluteUrl('javascript:alert(1)');//=> falseisAbsoluteUrl('javascript:alert(1)', {httpOnly: false});//=> true
Type Aliases
type Options
type Options = { /** Only allow HTTP(S) protocols.
When set to `false`, any valid absolute URL will be accepted, including potentially unsafe protocols like `javascript:`, `ftp:`, `ws:`, etc.
@default true
@example ``` import isAbsoluteUrl from 'is-absolute-url';
isAbsoluteUrl('javascript:alert(1)'); //=> false
isAbsoluteUrl('javascript:alert(1)', {httpOnly: false}); //=> true ``` */ readonly httpOnly?: boolean;};
Package Files (1)
Dependencies (0)
No dependencies.
Dev Dependencies (2)
Peer Dependencies (0)
No peer dependencies.
Badge
To add a badge like this oneto your package's README, use the codes available below.
You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/is-absolute-url
.
- Markdown[](https://www.jsdocs.io/package/is-absolute-url)
- HTML<a href="https://www.jsdocs.io/package/is-absolute-url"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>
- Updated .
Package analyzed in 2856 ms. - Missing or incorrect documentation? Open an issue for this package.