Socket
Socket
Sign inDemoInstall

normalize-package-data

Package Overview
Dependencies
1
Maintainers
1
Versions
59
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.0.7 to 0.0.9

32

lib/fixer.js

@@ -126,4 +126,32 @@ var semver = require("semver")

}
else if(data.bugs && typeof data.bugs == "string") {
data.bugs = {url: url}
else if(data.bugs)
if(typeof data.bugs == "string") {
data.bugs = {url: data.bugs}
}
else {
oldBugs = data.bugs
data.bugs = {}
if(oldBugs.url) {
if(typeof(oldBugs.url) == "string")
data.bugs.url = oldBugs.url
else
this.warn("bugs.url field must be a string. Deleted.")
}
if(oldBugs.email) {
if(typeof(oldBugs.email) == "string")
data.bugs.email = oldBugs.email
else
this.warn("bugs.email field must be a string. Deleted.")
}
}
if(!data.bugs.email && !data.bugs.url) {
delete data.bugs
this.warn("Normalized value of bugs field is an empty object. Deleted.")
}
}
, fixHomepageField: function(data) {
if(typeof data.homepage !== "string") {
this.warn("homepage field must be a string. Deleted.")
delete data.homepage
}

@@ -130,0 +158,0 @@ }

2

package.json
{
"name": "normalize-package-data",
"version": "0.0.7",
"version": "0.0.9",
"author": "Meryn Stol <merynstol@gmail.com>",

@@ -5,0 +5,0 @@ "description": "Normalizes data that can be found in package.json files.",

@@ -38,3 +38,3 @@ # normalize-package-data

## What normalization entails
## What normalization (currently) entails

@@ -55,2 +55,4 @@ * The value of `name` field gets trimmed

* If `bugs` field does not exist, but `repository` field points to a repository hosted on github, the value of the `bugs` field gets set to an url in the form of https://github.com/[owner-name]/[repo-name]/issues .
* If `bugs` field is an object, the resulting value only has email and url properties. If email and url properties are not strings, they are ignored. If no valid values for either email or url is found, bugs field will be removed.
* If `homepage` field is not a string, it will be removed.

@@ -57,0 +59,0 @@ ### Rules for name field

@@ -9,2 +9,3 @@ var tap = require("tap")

var data, clonedData
var warn

@@ -14,3 +15,7 @@ tap.test("consistent normalization", function(t) {

fs.readdir (__dirname + "/fixtures", function (err, entries) {
// entries = ['coffee-script.json'] // uncomment to limit to a specific file
verifyConsistency = function(entryName, next) {
warn = function(msg) {
// t.equal("",msg) // uncomment to have some kind of logging of warnings
}
filename = __dirname + "/fixtures/" + entryName

@@ -20,6 +25,6 @@ fs.readFile(filename, function(err, contents) {

data = JSON.parse(contents.toString())
normalize(data)
normalize(data, warn)
clonedData = _.clone(data)
normalize(data)
t.deepEqual(data, clonedData,
normalize(data, warn)
t.deepEqual(clonedData, data,
"Normalization of " + entryName + "is consistent.")

@@ -26,0 +31,0 @@ next(null)

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc