is-http-url
DefinitelyTyped icon, indicating that this package has TypeScript declarations provided by the separate @types/is-http-url package

2.0.0 • Public • Published

is-http-url

Validate URLs for sane values

Install

npm install is-http-url

Usage

Does the following:

  • Protocol should be one of http: or https:
  • Hostname should be valid domain name or IPv4 address (TODO: IPv6)
  • Port, if given, should be an integer in the range [1, 65535]

Example usage could be to validate the Origin or Referer HTTP headers

const assert = require('assert')
const isHttpUrl = require('is-http-url')
 
assert.ok(isHttpUrl('http://example.com/hello-world.txt'))
assert.notOk(isHttpUrl('//test'))
 

API

isHttpUrl(url)

url

Type: String

Related

License

ISC

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 2.0.0
    163
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 2.0.0
    163
  • 1.0.1
    0
  • 1.0.0
    0

Package Sidebar

Install

npm i is-http-url

Weekly Downloads

146

Version

2.0.0

License

ISC

Last publish

Collaborators

  • emilbayes
  • emilbay