Comparing version 0.3.1 to 0.4.0
11
index.js
var isURL = require("is-url") | ||
var URL = require("url") | ||
var qs = require("querystring") | ||
var urlRegex = require("url-regex") | ||
@@ -9,5 +10,13 @@ var redact = module.exports = function(input, replacement) { | ||
var isUrlWithPort = function(val) { | ||
if (isURL(val)) return true; | ||
if (urlRegex({strict: true, exact: true}).test(val)) return true; | ||
if (val.match(/^git\+(https?|ssl)/) && urlRegex({strict: true, exact: false}).test(val)) return true; | ||
return false; | ||
} | ||
// Require a URL or git+protocol URL-esque string | ||
// https://www.npmjs.org/doc/json.html#Git-URLs-as-Dependencies | ||
if (!isURL(input) && !input.match(/^git\+(https?|ssh)/)) return input | ||
if (!isUrlWithPort(input)) return input | ||
@@ -14,0 +23,0 @@ var url = URL.parse(input) |
{ | ||
"name": "redact-url", | ||
"version": "0.3.1", | ||
"version": "0.4.0", | ||
"description": "Redact or remove authentication data from URLs", | ||
@@ -28,7 +28,8 @@ "main": "index.js", | ||
"devDependencies": { | ||
"mocha": "^1.19.0" | ||
"mocha": "^5.2.0" | ||
}, | ||
"dependencies": { | ||
"is-url": "^1.1.0" | ||
"is-url": "^1.1.0", | ||
"url-regex": "^4.1.1" | ||
} | ||
} |
@@ -1,3 +0,1 @@ | ||
"use strict"; | ||
var mocha = require("mocha") | ||
@@ -32,7 +30,14 @@ var assert = require("assert") | ||
it("supports git+ssh URLs", function() { | ||
assert.equal(redact("git+ssh://zeke:password@github.com/zeke/outlet", ""), "git+ssh://github.com/zeke/outlet") | ||
assert.equal(redact("git+ssh://zeke:password@github.com/zeke/outlet", ""), "git+ssh://github.com/zeke/outlet") | ||
it("supports git+ssl URLs", function() { | ||
assert.equal(redact("git+ssl://zeke:password@github.com/zeke/outlet", ""), "git+ssl://github.com/zeke/outlet") | ||
}) | ||
it("supports URLs with ports", function() { | ||
assert.equal(redact("http://zeke:password@github.com:1234/zeke/outlet"), "http://REDACTED@github.com:1234/zeke/outlet") | ||
}); | ||
it("supports URLs unusual protocols", function() { | ||
assert.equal(redact("amqp://zeke:password@github.com:1234/zeke/outlet"), "amqp://REDACTED@github.com:1234/zeke/outlet") | ||
}); | ||
describe("redacts query parameters with secret-sounding names", function() { | ||
@@ -39,0 +44,0 @@ |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
6549
74
2
+ Addedurl-regex@^4.1.1
+ Addedip-regex@1.0.3(transitive)
+ Addedtlds@1.255.0(transitive)
+ Addedurl-regex@4.1.1(transitive)