New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

http-link-header

Package Overview
Dependencies
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

http-link-header - npm Package Compare versions

Comparing version 0.1.0 to 0.2.0

27

lib/link.js

@@ -47,3 +47,3 @@ var querystring = require( 'querystring' )

encoding: isCompatibleEncoding( parts[1] ) ?
undefined : parts[1].toLowerCase(),
null : parts[1].toLowerCase(),
value: isCompatibleEncoding( parts[1] ) ?

@@ -56,3 +56,3 @@ querystring.unescape( parts[3] ) : parts[3]

var parts = /([^\=\*]+)(\*)?\=(["']?)(.+)(\3)/.exec( attr )
var parts = /([^\=\*]+(\*)?)\=(["']?)(.+)(\3)/.exec( attr )
var key = parts[1].toLowerCase()

@@ -99,4 +99,20 @@ var hasEncoding = !!parts[2]

rel: function( value ) {
for( var i = 0; i < this.refs.length; i++ ) {
if( this.refs[ i ].rel === value ) {
return this.refs[ i ]
}
}
},
get: function( attr, value ) {
throw new Error( 'Not implemented' )
attr = attr.toLowerCase()
for( var i = 0; i < this.refs.length; i++ ) {
if( this.refs[ i ][ attr ] === value ) {
return this.refs[ i ]
}
}
},

@@ -112,2 +128,3 @@

var match = null
var link = null

@@ -118,3 +135,5 @@ // Unfold folded lines

while( match = pattern.exec( value ) ) {
this.refs.push( parseAttrs( parseLine( trim( match[0] ) ) ) )
link = parseAttrs( parseLine( trim( match[0] ) ) )
if( this.rel( link.rel ) != null ) continue;
this.refs.push( link )
}

@@ -121,0 +140,0 @@

4

package.json
{
"name": "http-link-header",
"version": "0.1.0",
"version": "0.2.0",
"description": "Parse & format HTTP link headers according to RFC 5988",

@@ -18,2 +18,3 @@ "author": "Jonas Hermsmeier <jhermsmeier@gmail.com> (https://jhermsmeier.de)",

"devDependencies": {
"matcha": "~0.7.0",
"mocha": "~3.1.0"

@@ -33,4 +34,5 @@ },

"scripts": {
"benchmark": "matcha --reporter plain",
"test": "mocha --ui tdd"
}
}

@@ -7,4 +7,6 @@ # HTTP Link Header

Parse & format HTTP link headers according to RFC 5988
Parse & format HTTP link headers according to [RFC 5988]
[RFC 5988]: https://tools.ietf.org/html/rfc5988
## Install via [npm](https://npmjs.com)

@@ -16,2 +18,11 @@

## Status
It can currently parse (almost) everything according to the RFC,
with exception of a few cases where control chars show up in attribute values:
- attribute contains semicolon
- attribute contains comma
- multiple links contain mixed comma & semicolon
## Usage

@@ -38,2 +49,7 @@

```js
link.rel( 'alternate' )
> { uri: 'example-01.com', rel: 'alternate', title: 'Alternate Example Domain' }
```
```js
link.has( 'rel', 'alternate' )

@@ -44,4 +60,4 @@ > true

```js
link.get( 'rel', 'alternate' )
link.get( 'title', 'alternate' )
> { uri: 'example-01.com', rel: 'alternate', title: 'Alternate Example Domain' }
```
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