Skip to content
Validate URLs for sane values
JavaScript
Branch: master
Clone or download

Latest commit

Fetching latest commit…
Cannot retrieve the latest commit at this time.

Files

Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
LICENSE.md
README.md
index.js
package.json
test.js

README.md

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

You can’t perform that action at this time.