ubdate
This commit is contained in:
46
node_modules/filenamify/index.js
generated
vendored
Normal file
46
node_modules/filenamify/index.js
generated
vendored
Normal file
@@ -0,0 +1,46 @@
|
||||
'use strict';
|
||||
const path = require('path');
|
||||
const trimRepeated = require('trim-repeated');
|
||||
const filenameReservedRegex = require('filename-reserved-regex');
|
||||
const stripOuter = require('strip-outer');
|
||||
|
||||
// Doesn't make sense to have longer filenames
|
||||
const MAX_FILENAME_LENGTH = 100;
|
||||
|
||||
const reControlChars = /[\u0000-\u001f\u0080-\u009f]/g; // eslint-disable-line no-control-regex
|
||||
const reRelativePath = /^\.+/;
|
||||
|
||||
const fn = (string, options) => {
|
||||
if (typeof string !== 'string') {
|
||||
throw new TypeError('Expected a string');
|
||||
}
|
||||
|
||||
options = options || {};
|
||||
|
||||
const replacement = options.replacement === undefined ? '!' : options.replacement;
|
||||
|
||||
if (filenameReservedRegex().test(replacement) && reControlChars.test(replacement)) {
|
||||
throw new Error('Replacement string cannot contain reserved filename characters');
|
||||
}
|
||||
|
||||
string = string.replace(filenameReservedRegex(), replacement);
|
||||
string = string.replace(reControlChars, replacement);
|
||||
string = string.replace(reRelativePath, replacement);
|
||||
|
||||
if (replacement.length > 0) {
|
||||
string = trimRepeated(string, replacement);
|
||||
string = string.length > 1 ? stripOuter(string, replacement) : string;
|
||||
}
|
||||
|
||||
string = filenameReservedRegex.windowsNames().test(string) ? string + replacement : string;
|
||||
string = string.slice(0, MAX_FILENAME_LENGTH);
|
||||
|
||||
return string;
|
||||
};
|
||||
|
||||
fn.path = (pth, options) => {
|
||||
pth = path.resolve(pth);
|
||||
return path.join(path.dirname(pth), fn(path.basename(pth), options));
|
||||
};
|
||||
|
||||
module.exports = fn;
|
||||
9
node_modules/filenamify/license
generated
vendored
Normal file
9
node_modules/filenamify/license
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
76
node_modules/filenamify/package.json
generated
vendored
Normal file
76
node_modules/filenamify/package.json
generated
vendored
Normal file
@@ -0,0 +1,76 @@
|
||||
{
|
||||
"_from": "filenamify@^2.0.0",
|
||||
"_id": "filenamify@2.1.0",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-ICw7NTT6RsDp2rnYKVd8Fu4cr6ITzGy3+u4vUujPkabyaz+03F24NWEX7fs5fp+kBonlaqPH8fAO2NM+SXt/JA==",
|
||||
"_location": "/filenamify",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "range",
|
||||
"registry": true,
|
||||
"raw": "filenamify@^2.0.0",
|
||||
"name": "filenamify",
|
||||
"escapedName": "filenamify",
|
||||
"rawSpec": "^2.0.0",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "^2.0.0"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/bin-wrapper/download",
|
||||
"/download"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/filenamify/-/filenamify-2.1.0.tgz",
|
||||
"_shasum": "88faf495fb1b47abfd612300002a16228c677ee9",
|
||||
"_spec": "filenamify@^2.0.0",
|
||||
"_where": "/var/www/html/jason/WeihnachtenMelly/node_modules/download",
|
||||
"author": {
|
||||
"name": "Sindre Sorhus",
|
||||
"email": "sindresorhus@gmail.com",
|
||||
"url": "sindresorhus.com"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/sindresorhus/filenamify/issues"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"dependencies": {
|
||||
"filename-reserved-regex": "^2.0.0",
|
||||
"strip-outer": "^1.0.0",
|
||||
"trim-repeated": "^1.0.0"
|
||||
},
|
||||
"deprecated": false,
|
||||
"description": "Convert a string to a valid safe filename",
|
||||
"devDependencies": {
|
||||
"ava": "*",
|
||||
"xo": "*"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=4"
|
||||
},
|
||||
"files": [
|
||||
"index.js"
|
||||
],
|
||||
"homepage": "https://github.com/sindresorhus/filenamify#readme",
|
||||
"keywords": [
|
||||
"filename",
|
||||
"safe",
|
||||
"sanitize",
|
||||
"file",
|
||||
"name",
|
||||
"string",
|
||||
"path",
|
||||
"filepath",
|
||||
"convert",
|
||||
"valid",
|
||||
"dirname"
|
||||
],
|
||||
"license": "MIT",
|
||||
"name": "filenamify",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/sindresorhus/filenamify.git"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "xo && ava"
|
||||
},
|
||||
"version": "2.1.0"
|
||||
}
|
||||
64
node_modules/filenamify/readme.md
generated
vendored
Normal file
64
node_modules/filenamify/readme.md
generated
vendored
Normal file
@@ -0,0 +1,64 @@
|
||||
# filenamify [](https://travis-ci.org/sindresorhus/filenamify)
|
||||
|
||||
> Convert a string to a valid safe filename
|
||||
|
||||
On Unix-like systems `/` is reserved and [`<>:"/\|?*`](http://msdn.microsoft.com/en-us/library/aa365247%28VS.85%29#naming_conventions) on Windows.
|
||||
|
||||
|
||||
## Install
|
||||
|
||||
```
|
||||
$ npm install filenamify
|
||||
```
|
||||
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
const filenamify = require('filenamify');
|
||||
|
||||
filenamify('<foo/bar>');
|
||||
//=> 'foo!bar'
|
||||
|
||||
filenamify('foo:"bar"', {replacement: '🐴'});
|
||||
//=> 'foo🐴bar'
|
||||
```
|
||||
|
||||
|
||||
## API
|
||||
|
||||
### filenamify(input, [options])
|
||||
|
||||
Accepts a filename and returns a valid filename.
|
||||
|
||||
### filenamify.path(input, [options])
|
||||
|
||||
Accepts a path and returns the path with a valid filename.
|
||||
|
||||
#### input
|
||||
|
||||
Type: `string`
|
||||
|
||||
#### options
|
||||
|
||||
##### replacement
|
||||
|
||||
Type: `string`<br>
|
||||
Default: `'!'`
|
||||
|
||||
String to use as replacement for reserved filename characters.
|
||||
|
||||
Cannot contain: `<` `>` `:` `"` `/` `\` `|` `?` `*`
|
||||
|
||||
|
||||
## Related
|
||||
|
||||
- [filenamify-url](https://github.com/sindresorhus/filenamify-url) - Convert a URL to a valid filename
|
||||
- [valid-filename](https://github.com/sindresorhus/valid-filename) - Check if a string is a valid filename
|
||||
- [unused-filename](https://github.com/sindresorhus/unused-filename) - Get a unused filename by appending a number if it exists
|
||||
- [slugify](https://github.com/sindresorhus/slugify) - Slugify a string
|
||||
|
||||
|
||||
## License
|
||||
|
||||
MIT © [Sindre Sorhus](https://sindresorhus.com)
|
||||
Reference in New Issue
Block a user