Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

format-link-header

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

format-link-header

Format a link header object, to the original RFC 5988

  • 3.1.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2.7K
increased by27.86%
Maintainers
1
Weekly downloads
 
Created
Source

npm Build Status

Allows to format a given links ref object, to the format as described in RFC 5988. Precisely it achieves the exactly inverse process performed by the parse-link-header.

Installation

  npm install --save format-link-header

Usage

  1. Given a links refs object generated by parse-link-header:
  const link = {
    next: {
      page: '3',
      per_page: '100',
      rel: 'next',
      url: 'https://api.github.com/user/9287/repos?page=3&per_page=100'
    },
    prev: {
      page: '1',
      per_page: '100',
      rel: 'prev',
      pet: 'cat',
      url: 'https://api.github.com/user/9287/repos?page=1&per_page=100'
    },
    last: {
      page: '5',
      per_page: '100',
      rel: 'last',
      url: 'https://api.github.com/user/9287/repos?page=5&per_page=100'
    }
  }
  1. Format the link header
  const formatLink = require('format-link-header');
  const linkHeaderString = formatLink(link);
  1. Web link headers generated!
  <https://api.github.com/user/9287/repos?page=3&per_page=100>; rel="next", <https://api.github.com/user/9287/repos?page=1&per_page=100>; rel="prev"; pet="cat", <https://api.github.com/user/9287/repos?page=5&per_page=100>; rel="last"

Keywords

FAQs

Package last updated on 08 Dec 2020

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc