link-types
Advanced tools
Comparing version 1.0.0 to 1.1.0
35
index.js
@@ -14,3 +14,3 @@ "use strict"; | ||
{ | ||
return attrValue.trim().toLowerCase().split(" ").filter(isNotEmpty); | ||
return split(attrValue).filter(isNotEmpty); | ||
} | ||
@@ -20,2 +20,35 @@ | ||
function map(attrValue) | ||
{ | ||
var i,numValues,value,result; | ||
attrValue = split(attrValue); | ||
numValues = attrValue.length; | ||
result = {}; | ||
for (i=0; i<numValues; i++) | ||
{ | ||
value = attrValue[i]; | ||
if (value !== "") | ||
{ | ||
result[value] = true; | ||
} | ||
} | ||
return result; | ||
} | ||
function split(attrValue) | ||
{ | ||
return attrValue.trim().toLowerCase().split(" "); | ||
} | ||
linkTypes.map = map; | ||
module.exports = linkTypes; |
{ | ||
"name": "link-types", | ||
"description": "Parse an HTML attribute value containing link types.", | ||
"version": "1.0.0", | ||
"version": "1.1.0", | ||
"license": "MIT", | ||
@@ -6,0 +6,0 @@ "homepage": "https://github.com/stevenvachon/link-types", |
@@ -20,5 +20,11 @@ # link-types [![NPM Version][npm-image]][npm-url] [![Build Status][travis-image]][travis-url] | ||
var linkTypes = require("link-types"); | ||
linkTypes("nofollow"); | ||
//=> ["nofollow"] | ||
linkTypes(" tag NOFOLLOW "); | ||
//=> ["tag", "nofollow"] | ||
linkTypes.map(" tag NOFOLLOW "); | ||
//=> { tag:true, nofollow:true } | ||
``` | ||
@@ -25,0 +31,0 @@ |
Trivial Package
Supply chain riskPackages less than 10 lines of code are easily copied into your own project and may not warrant the additional supply chain risk of an external dependency.
Found 1 instance in 1 package
3389
31
36
0