first commit
This commit is contained in:
43
build/node_modules/filenamify/index.js
generated
vendored
Normal file
43
build/node_modules/filenamify/index.js
generated
vendored
Normal file
@@ -0,0 +1,43 @@
|
||||
'use strict';
|
||||
var path = require('path');
|
||||
var trimRepeated = require('trim-repeated');
|
||||
var filenameReservedRegex = require('filename-reserved-regex');
|
||||
var stripOuter = require('strip-outer');
|
||||
|
||||
// doesn't make sense to have longer filenames
|
||||
var MAX_FILENAME_LENGTH = 100;
|
||||
|
||||
var reControlChars = /[\x00-\x1f\x80-\x9f]/g;
|
||||
var reRelativePath = /^\.+/;
|
||||
|
||||
var fn = module.exports = function (str, opts) {
|
||||
if (typeof str !== 'string') {
|
||||
throw new TypeError('Expected a string');
|
||||
}
|
||||
|
||||
opts = opts || {};
|
||||
|
||||
var replacement = opts.replacement || '!';
|
||||
|
||||
if (filenameReservedRegex().test(replacement) && reControlChars.test(replacement)) {
|
||||
throw new Error('Replacement string cannot contain reserved filename characters');
|
||||
}
|
||||
|
||||
str = str.replace(filenameReservedRegex(), replacement);
|
||||
str = str.replace(reControlChars, replacement);
|
||||
str = str.replace(reRelativePath, replacement);
|
||||
|
||||
if (replacement.length > 0) {
|
||||
str = trimRepeated(str, replacement);
|
||||
str = str.length > 1 ? stripOuter(str, replacement) : str;
|
||||
}
|
||||
|
||||
str = str.slice(0, MAX_FILENAME_LENGTH);
|
||||
|
||||
return str;
|
||||
};
|
||||
|
||||
fn.path = function (pth, opts) {
|
||||
pth = path.resolve(pth);
|
||||
return path.join(path.dirname(pth), fn(path.basename(pth), opts));
|
||||
};
|
||||
21
build/node_modules/filenamify/license
generated
vendored
Normal file
21
build/node_modules/filenamify/license
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
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.
|
||||
78
build/node_modules/filenamify/package.json
generated
vendored
Normal file
78
build/node_modules/filenamify/package.json
generated
vendored
Normal file
@@ -0,0 +1,78 @@
|
||||
{
|
||||
"_args": [
|
||||
[
|
||||
"filenamify@1.2.1",
|
||||
"/Users/asciidisco/Desktop/asciidisco.com/build"
|
||||
]
|
||||
],
|
||||
"_from": "filenamify@1.2.1",
|
||||
"_id": "filenamify@1.2.1",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha1-qfL/0RxQO+0wABUCknI3jx8TZaU=",
|
||||
"_location": "/filenamify",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "version",
|
||||
"registry": true,
|
||||
"raw": "filenamify@1.2.1",
|
||||
"name": "filenamify",
|
||||
"escapedName": "filenamify",
|
||||
"rawSpec": "1.2.1",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "1.2.1"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/download"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/filenamify/-/filenamify-1.2.1.tgz",
|
||||
"_spec": "1.2.1",
|
||||
"_where": "/Users/asciidisco/Desktop/asciidisco.com/build",
|
||||
"author": {
|
||||
"name": "Sindre Sorhus",
|
||||
"email": "sindresorhus@gmail.com",
|
||||
"url": "sindresorhus.com"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/sindresorhus/filenamify/issues"
|
||||
},
|
||||
"dependencies": {
|
||||
"filename-reserved-regex": "^1.0.0",
|
||||
"strip-outer": "^1.0.0",
|
||||
"trim-repeated": "^1.0.0"
|
||||
},
|
||||
"description": "Convert a string to a valid safe filename",
|
||||
"devDependencies": {
|
||||
"ava": "*",
|
||||
"xo": "*"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
},
|
||||
"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": "1.2.1"
|
||||
}
|
||||
62
build/node_modules/filenamify/readme.md
generated
vendored
Normal file
62
build/node_modules/filenamify/readme.md
generated
vendored
Normal file
@@ -0,0 +1,62 @@
|
||||
# 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 --save 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
|
||||
|
||||
|
||||
## License
|
||||
|
||||
MIT © [Sindre Sorhus](https://sindresorhus.com)
|
||||
Reference in New Issue
Block a user