Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

redact-url

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

redact-url - npm Package Compare versions

Comparing version 0.3.1 to 0.4.0

LICENSE

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)

7

package.json
{
"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

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