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

filenamify

Package Overview
Dependencies
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

filenamify - npm Package Compare versions

Comparing version 5.1.1 to 6.0.0

4

filenamify-path.d.ts

@@ -1,2 +0,2 @@

import {Options} from './filenamify.js';
import {type Options} from './filenamify.js';

@@ -16,2 +16,2 @@ /**

export {Options} from './filenamify.js';
export type {Options} from './filenamify.js';

@@ -1,2 +0,2 @@

export interface Options {
export type Options = {
/**

@@ -21,3 +21,3 @@ String to use as replacement for reserved filename characters.

readonly maxLength?: number;
}
};

@@ -32,8 +32,8 @@ /**

filenamify('<foo/bar>');
//=> 'foo!bar'
//=> '!foo!bar!'
filenamify('foo:"bar"', {replacement: '🐴'});
//=> 'foo🐴bar'
//=> 'foo🐴bar🐴'
```
*/
export default function filenamify(string: string, options?: Options): string;

@@ -1,4 +0,2 @@

import trimRepeated from 'trim-repeated';
import filenameReservedRegex, {windowsReservedNameRegex} from 'filename-reserved-regex';
import stripOuter from 'strip-outer';

@@ -8,3 +6,2 @@ // Doesn't make sense to have longer filenames

const reControlChars = /[\u0000-\u001F\u0080-\u009F]/g; // eslint-disable-line no-control-regex
const reRelativePath = /^\.+(\\|\/)|^\.+$/;

@@ -14,2 +11,5 @@ const reTrailingPeriods = /\.+$/;

export default function filenamify(string, options = {}) {
const reControlChars = /[\u0000-\u001F\u0080-\u009F]/g; // eslint-disable-line no-control-regex
const reRepeatedReservedCharacters = /([<>:"/\\|?*\u0000-\u001F]){2,}/g; // eslint-disable-line no-control-regex
if (typeof string !== 'string') {

@@ -25,2 +25,6 @@ throw new TypeError('Expected a string');

if (replacement.length > 0) {
string = string.replace(reRepeatedReservedCharacters, '$1');
}
string = string.normalize('NFD');

@@ -35,5 +39,2 @@ string = string.replace(reRelativePath, replacement);

string = trimRepeated(string, replacement);
string = string.length > 1 ? stripOuter(string, replacement) : string;
// We removed the whole filename

@@ -40,0 +41,0 @@ if (!startedWithDot && string[0] === '.') {

{
"name": "filenamify",
"version": "5.1.1",
"version": "6.0.0",
"description": "Convert a string to a valid safe filename",

@@ -19,3 +19,3 @@ "license": "MIT",

"engines": {
"node": ">=12.20"
"node": ">=16"
},

@@ -47,11 +47,9 @@ "scripts": {

"dependencies": {
"filename-reserved-regex": "^3.0.0",
"strip-outer": "^2.0.0",
"trim-repeated": "^2.0.0"
"filename-reserved-regex": "^3.0.0"
},
"devDependencies": {
"ava": "^3.15.0",
"tsd": "^0.18.0",
"xo": "^0.45.0"
"ava": "^5.2.0",
"tsd": "^0.28.1",
"xo": "^0.54.1"
}
}

@@ -19,6 +19,6 @@ # filenamify

filenamify('<foo/bar>');
//=> 'foo!bar'
//=> '!foo!bar!'
filenamify('foo:"bar"', {replacement: '🐴'});
//=> 'foo🐴bar'
//=> 'foo🐴bar🐴'
```

@@ -75,3 +75,3 @@

filenamify('<foo/bar>');
//=> 'foo!bar'
//=> '!foo!bar!'
```

@@ -78,0 +78,0 @@

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