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.

Readme

Keywords

Package Sidebar

Install

npm i request-destination

Weekly Downloads

1

Version

1.0.0

License

ISC

Unpacked Size

5.95 kB

Total Files

7

Last publish

Collaborators

  • seb