Socket
Socket
Sign inDemoInstall

sanitize-filename

Package Overview
Dependencies
2
Maintainers
1
Versions
22
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.6.1 to 1.6.2

.airtap.yml

5

index.js

@@ -33,3 +33,3 @@ /*jshint node:true*/

var illegalRe = /[\/\?<>\\:\*\|":]/g;
var illegalRe = /[\/\?<>\\:\*\|"]/g;
var controlRe = /[\x00-\x1f\x80-\x9f]/g;

@@ -41,2 +41,5 @@ var reservedRe = /^\.+$/;

function sanitize(input, replacement) {
if (typeof input !== 'string') {
throw new Error('Input must be string');
}
var sanitized = input

@@ -43,0 +46,0 @@ .replace(illegalRe, replacement)

12

package.json
{
"name": "sanitize-filename",
"version": "1.6.1",
"version": "1.6.2",
"description": "Sanitize a string for use as a filename",

@@ -22,4 +22,4 @@ "keywords": [

"test": "tape test.js",
"test-browser": "zuul --local --open -- test.js",
"test-browser-sauce": "zuul -- test.js"
"test-browser": "airtap --local --open -- test.js",
"test-browser-sauce": "airtap -- test.js"
},

@@ -30,8 +30,8 @@ "dependencies": {

"devDependencies": {
"browserify": "^13.0.0",
"airtap": "^2.0.3",
"browserify": "^14.0.0",
"concat-stream": "^1.5.1",
"mktemp": "^0.4.0",
"tape": "^4.2.2",
"zuul": "^3.7.2"
"tape": "^4.2.2"
}
}

@@ -99,3 +99,6 @@ # sanitize-filename [![build status](https://secure.travis-ci.org/parshap/node-sanitize-filename.svg?branch=master)](http://travis-ci.org/parshap/node-sanitize-filename)

* `options.replacement`: A string to replace invalid characters with.
*Optional. Default: `""`.*
* `options.replacement`: *optional, string/function, default: `""`*. If passed
as a string, it's used as the replacement for invalid characters. If passed as
a function, the function will be called with the invalid characters and it's
return value will be used as the replacement. See [`String.prototype.replace`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace)
for more info.

@@ -145,2 +145,35 @@ "use strict";

// Test invalid input
//
test("invalid input", function(t) {
t.throws(function() {
sanitize();
}, null, 'no arguments');
[
undefined,
null,
false,
true,
{},
{
replace: function() {
return "foo";
},
toString: function() {
return "bar";
},
},
[],
new Buffer('asdf'),
].forEach(function(input) {
t.throws(function() {
sanitize(input);
}, null, JSON.stringify(input));
});
t.end();
});
function testStringUsingFS(str, t) {

@@ -147,0 +180,0 @@ var sanitized = sanitize(str) || "default";

Sorry, the diff of this file is not supported yet

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