request-destination

1.0.0 • Public • Published

request-destination 🔮

Guess the fetch API request destination based on a file path.

Use Case

Useful when generating Link rel=preload headers for HTTP/2 Server Push and other web performance optimisations.

https://fetch.spec.whatwg.org/#concept-request-destination

Installation

npm install request-destination

Usage

const {requestDestination} = require('request-destination')
 
requestDestination('/foo.js')   // 'script'
requestDestination('/bar.css')  // 'style'
requestDestination('/bla.woff') // 'font'
requestDestination('/lol.html') // ''
requestDestination('/abc')      // ''

Colophon

Made with ❤️ by Sebastiaan Deckers.

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 1.0.0
    2
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 1.0.0
    2

Package Sidebar

Install

npm i request-destination

Weekly Downloads

2

Version

1.0.0

License

ISC

Unpacked Size

5.95 kB

Total Files

7

Last publish

Collaborators

  • seb