MCPcopy Index your code
hub / github.com/OpenSignLabs/OpenSign / buildDownloadFilename

Function buildDownloadFilename

apps/OpenSign/src/utils/fileUtils.js:90–125  ·  view source on GitHub ↗
(formatId, ctx)

Source from the content-addressed store, hash-verified

88 * @returns {string}
89 */
90export function buildDownloadFilename(formatId, ctx) {
91 const {
92 docName = "Document",
93 email = "user@example.com",
94 date = new Date(),
95 ext = "pdf",
96 isSigned = false
97 } = ctx || {};
98
99 const base = sanitizeDownloadFilename(String(docName) || "Document");
100 const safeEmail = sanitizeDownloadFilename(
101 String(email) || "user@example.com"
102 );
103 const dateStr = formatFixedDate(date);
104
105 let stem;
106 switch (formatId) {
107 case "DOCNAME":
108 stem = base;
109 break;
110 case "DOCNAME_SIGNED":
111 stem = isSigned ? `${base} - Signed` : base; // if not signed, fallback to base
112 break;
113 case "DOCNAME_EMAIL":
114 stem = `${base} - ${safeEmail}`;
115 break;
116 case "DOCNAME_EMAIL_DATE":
117 stem = `${base} - ${safeEmail} - ${dateStr}`;
118 break;
119 default:
120 stem = base; // safe default
121 }
122
123 const safeExt = ext.replace(/\.+/g, "").toLowerCase() || "pdf";
124 return `${stem}.${safeExt}`;
125}
126
127export function parseCSV(text) {
128 const rows = [];

Callers 2

FilenameFormatSelectorFunction · 0.90
handleDownloadPdfFunction · 0.90

Calls 2

sanitizeDownloadFilenameFunction · 0.70
formatFixedDateFunction · 0.70

Tested by

no test coverage detected