MCPcopy Index your code
hub / github.com/node-formidable/formidable / _setUpRename

Method _setUpRename

src/Formidable.js:609–637  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

607 }
608
609 _setUpRename() {
610 const hasRename = typeof this.options.filename === 'function';
611 if (hasRename) {
612 this._getNewName = (part) => {
613 let ext = '';
614 let name = this.options.defaultInvalidName;
615 if (part.originalFilename) {
616 // can be null
617 ({ ext, name } = path.parse(part.originalFilename));
618 if (this.options.keepExtensions !== true) {
619 ext = '';
620 }
621 }
622 return this.options.filename.call(this, name, ext, part, this);
623 };
624 } else {
625 this._getNewName = (part) => {
626 const name = createId();
627
628 if (part && this.options.keepExtensions) {
629 const originalFilename =
630 typeof part === 'string' ? part : part.originalFilename;
631 return `${name}${this._getExtension(originalFilename)}`;
632 }
633
634 return name;
635 };
636 }
637 }
638
639 _setUpMaxFields() {
640 if (this.options.maxFields !== Infinity) {

Callers 1

constructorMethod · 0.95

Calls 2

_getExtensionMethod · 0.95
parseMethod · 0.80

Tested by

no test coverage detected