http-get-pathname

2.0.0 • Public • Published

http-get-pathname

Extract and cache the pathname string of an http request

Call this function on an incoming HTTP request in one or more places without worrying about performance/caching and without any prior parsing of the request/url

The leading slash is stripped by default

If you like the style, check out http-body-parse http-query-parse which shares some caching and thus works great together

Installation

npm install http-get-pathname

Usage

The result is cached and subsequent calls are cheap

var httpGetPathname = require('http-get-pathname');
 
// http://localhost/path/name?someQueryString
 
httpGetPathname(request); // path/name
 
// second call is cheap
httpGetPathname(request); // path/name
 
// with leading slash
httpGetPathname(request, true); // /path/name

License

MIT © src.agency

Versions

Current Tags

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

Version History

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

Package Sidebar

Install

npm i http-get-pathname

Weekly Downloads

2

Version

2.0.0

License

MIT

Last publish

Collaborators

  • thomas-jensen