find-reachable-urls

Passes back all URLs which respond with status code 200.

MIT 4 个版本
安装
npm install find-reachable-urls
yarn add find-reachable-urls
pnpm add find-reachable-urls
bun add find-reachable-urls
README

find-reachable-urls Build Status

Passes back all URLs which respond with status code 200.

Installation

npm install find-reachable-urls --save

Usage

const findReachableUrls = require('find-reachable-urls')
const urls = [
  'https://google.com', // 200
  'https://github.com/nonexistent-url', // 404
  'https://github.com/OctoLinker/chrome-extension', // 301
]

findReachableUrls(urls)
  .then(function(result) {
    console.log(result)
    // ['https://google.com', 'https://github.com/OctoLinker/chrome-extension']
  })
  .catch(function(err) {
    // handle error
  })

findReachableUrls(urls, [options], [callback])

Returns a Promise with all reachable urls.

urls

Type: string, array

The URL(s) to check.

options

Type: object

firstMatch

Type: boolean

Default: false

If true it returns the first reachable url and stops any further requests. If none of the urls is reachable it returns undefined.

Tests

npm install
npm test
  • heads: Make parallel HEAD requests for an array of URLs and get back their HTTP status codes.

License

MIT

版本列表
1.1.1 2017-04-06
1.1.0 2017-04-06
1.0.0 2017-02-21
0.1.0 2017-02-20