MCPcopy
hub / github.com/node-formidable/formidable / _getFileName

Method _getFileName

src/Formidable.js:551–566  ·  view source on GitHub ↗
(headerValue)

Source from the content-addressed store, hash-verified

549 }
550
551 _getFileName(headerValue) {
552 // matches either a quoted-string or a token (RFC 2616 section 19.5.1)
553 const m = headerValue.match(
554 /\bfilename=("(.*?)"|([^()<>{}[\]@,;:"?=\s/\t]+))($|;\s)/i,
555 );
556 if (!m) return null;
557
558 const match = m[2] || m[3] || '';
559 let originalFilename = match.substr(match.lastIndexOf('\\') + 1);
560 originalFilename = originalFilename.replace(/%22/g, '"');
561 originalFilename = originalFilename.replace(/&#([\d]{4});/g, (_, code) =>
562 String.fromCharCode(code),
563 );
564
565 return originalFilename;
566 }
567
568 // able to get composed extension with multiple dots
569 // "a.b.c" -> ".b.c"

Callers 2

formidable.test.jsFile · 0.80
createInitMultipartFunction · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected