Socket
Socket
Sign inDemoInstall

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 4.3.0 to 5.0.0

6

filenamify-path.d.ts

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

import filenamify = require('./filenamify');
import {Options} from './filenamify.js';

@@ -6,4 +6,2 @@ /**

*/
declare const filenamifyPath: (path: string, options?: filenamify.Options) => string;
export = filenamifyPath;
export default function filenamifyPath(path: string, options?: Options): string;

@@ -1,10 +0,7 @@

'use strict';
const path = require('path');
const filenamify = require('./filenamify');
import path from 'node:path';
import filenamify from './filenamify.js';
const filenamifyPath = (filePath, options) => {
export default function filenamifyPath(filePath, options) {
filePath = path.resolve(filePath);
return path.join(path.dirname(filePath), filenamify(path.basename(filePath), options));
};
module.exports = filenamifyPath;
}

@@ -1,21 +0,19 @@

declare namespace filenamify {
interface Options {
/**
String to use as replacement for reserved filename characters.
export interface Options {
/**
String to use as replacement for reserved filename characters.
Cannot contain: `<` `>` `:` `"` `/` `\` `|` `?` `*`
Cannot contain: `<` `>` `:` `"` `/` `\` `|` `?` `*`
@default '!'
*/
readonly replacement?: string;
@default '!'
*/
readonly replacement?: string;
/**
Truncate the filename to the given length.
/**
Truncate the filename to the given length.
Systems generally allow up to 255 characters, but we default to 100 for usability reasons.
Systems generally allow up to 255 characters, but we default to 100 for usability reasons.
@default 100
*/
readonly maxLength?: number;
}
@default 100
*/
readonly maxLength?: number;
}

@@ -28,3 +26,3 @@

```
import filenamify = require('filenamify');
import filenamify from 'filenamify';

@@ -38,4 +36,2 @@ filenamify('<foo/bar>');

*/
declare const filenamify: (string: string, options?: filenamify.Options) => string;
export = filenamify;
export default function filenamify(string: string, options?: Options): string;

@@ -1,5 +0,4 @@

'use strict';
const trimRepeated = require('trim-repeated');
const filenameReservedRegex = require('filename-reserved-regex');
const stripOuter = require('strip-outer');
import trimRepeated from 'trim-repeated';
import filenameReservedRegex from 'filename-reserved-regex';
import stripOuter from 'strip-outer';

@@ -9,7 +8,7 @@ // Doesn't make sense to have longer filenames

const reControlChars = /[\u0000-\u001f\u0080-\u009f]/g; // eslint-disable-line no-control-regex
const reControlChars = /[\u0000-\u001F\u0080-\u009F]/g; // eslint-disable-line no-control-regex
const reRelativePath = /^\.+/;
const reTrailingPeriods = /\.+$/;
const filenamify = (string, options = {}) => {
export default function filenamify(string, options = {}) {
if (typeof string !== 'string') {

@@ -39,4 +38,2 @@ throw new TypeError('Expected a string');

return string;
};
module.exports = filenamify;
}

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

import filenamify = require('./filenamify');
import filenamifyPath = require('./filenamify-path');
declare const filenamifyCombined: {
/**
Convert a string to a valid filename.
@example
```
import filenamify = require('filenamify');
filenamify('<foo/bar>');
//=> 'foo!bar'
filenamify('foo:"bar"', {replacement: '🐴'});
//=> 'foo🐴bar'
```
*/
(string: string, options?: filenamify.Options): string;
path: typeof filenamifyPath;
};
export = filenamifyCombined;
export {default} from './filenamify.js';
export {default as filenamifyPath} from './filenamify-path.js';

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

'use strict';
const filenamify = require('./filenamify');
const filenamifyPath = require('./filenamify-path');
const filenamifyCombined = filenamify;
filenamifyCombined.path = filenamifyPath;
module.exports = filenamify;
export {default} from './filenamify.js';
export {default as filenamifyPath} from './filenamify-path.js';
{
"name": "filenamify",
"version": "4.3.0",
"version": "5.0.0",
"description": "Convert a string to a valid safe filename",

@@ -13,4 +13,9 @@ "license": "MIT",

},
"type": "module",
"exports": {
".": "./index.js",
"./browser": "./filenamify.js"
},
"engines": {
"node": ">=8"
"node": ">=12.20"
},

@@ -28,6 +33,2 @@ "scripts": {

],
"exports": {
".": "./index.js",
"./browser": "./filenamify.js"
},
"keywords": [

@@ -52,6 +53,6 @@ "filename",

"devDependencies": {
"ava": "^1.4.1",
"tsd": "^0.7.1",
"xo": "^0.24.0"
"ava": "^3.15.0",
"tsd": "^0.17.0",
"xo": "^0.40.3"
}
}

@@ -16,3 +16,3 @@ # filenamify

```js
const filenamify = require('filenamify');
import filenamify from 'filenamify';

@@ -32,3 +32,3 @@ filenamify('<foo/bar>');

### filenamify.path(path, options?)
### filenamifyPath(path, options?)

@@ -64,3 +64,3 @@ Convert the filename in a path a valid filename and return the augmented path.

```js
const filenamify = require('filenamify/browser');
import filenamify from 'filenamify/browser';

@@ -67,0 +67,0 @@ filenamify('<foo/bar>');

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