1.0.0 • Published 2 years ago

md-url-checker v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

This is a NodeJS module to extract url links — with an option to see if the links are broken or not — from a markdown file or a file following markdown syntax of the type:

[link](http(s)://domain.com/yadayada)

The module returns an array of objects with the list of links found in the files within a folder especified when calling the module with the option to add the status code returned when acessing the url.

Project developed using the following technologies:

  • NodeJS

npm install md-url-checker

There are two ways to use this module

Directly on terminal:

md-url-checker folderPath --option

where,

  • folderPath: is the relative or absolute path to the folder with the files you wish to analize.
  • --option: is an available option as listed here. option --check|-c

Importing function getUrl()

getUrl(folderPath: 'string', option: 'string');

Use examples:

import checker from "md-url-checker";

checker.getUrl("./files"); // returns array of objects with links found in files
checker.getUrl("./files" , "--check"); // returns array of objects with links and status code
checker.getUrl("./files" , "-c"); // returns array of objects with links and status code

The first example returns an array of arrays — if there are multiple files in ./files— with the format:

[
  [
    {
      LinkFoo: 'https://bar.barz',
    }
  ]
  [
    {
      LinkDarth: 'https://darkside.join/how-to-increase-your-power-10x',
    }
  ]
]

The second and third examples are equivalent and return an array of arrays — if there are multiple files in ./files— with the format:

[
  [
    {
      LinkFoo: 'https://bar.barz',
      status: '200 - OK'
    }
  ]
  [
    {
      LinkDarth: 'https://darkside.join/how-to-increase-your-power-10x',
      status: '404 - Not Found'
    }
  ]
]

--check | -c

  • checks the urls status codes and return an object with url and status code with the following format:
[
    {
      LinkFoo: 'https://bar.barz',
      status: '200 - OK'
    },
    {
      LinkDarth: 'https://darkside.join/how-to-increase-your-power-10x',
      status: '404 - Not Found'
    }
]