Socket
Book a DemoInstallSign in
Socket

is-absolute-url

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

is-absolute-url

Check if a URL is absolute

latest
Source
npmnpm
Version
5.0.0
Version published
Weekly downloads
3.6M
8.12%
Maintainers
1
Weekly downloads
 
Created
Source

is-absolute-url

Check if a URL is absolute

Install

npm install is-absolute-url

Usage

import isAbsoluteUrl from 'is-absolute-url';

isAbsoluteUrl('https://sindresorhus.com/foo/bar');
//=> true

isAbsoluteUrl('//sindresorhus.com');
//=> false

isAbsoluteUrl('foo/bar');
//=> false

isAbsoluteUrl('javascript:alert(1)');
//=> false

isAbsoluteUrl('javascript:alert(1)', {httpOnly: false});
//=> true

API

isAbsoluteUrl(url, options?)

url

Type: string

The URL to check.

options

Type: object

httpOnly

Type: boolean
Default: true

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.

Warning: Setting httpOnly to false can pose security risks as it will return true for URLs with protocols like javascript:, vbscript:, data:, ftp:, ws:, etc. Only set this to false if you understand the implications and have appropriate safeguards in place.

See is-relative-url for the inverse.

Keywords

url

FAQs

Package last updated on 13 Sep 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts