MCPcopy Create free account
hub / github.com/electron/clerk / updatePRBodyForNoNotes

Function updatePRBodyForNoNotes

src/note-utils.ts:7–29  ·  view source on GitHub ↗
(body: string | null)

Source from the content-addressed store, hash-verified

5const debug = d('note-utils');
6
7export const updatePRBodyForNoNotes = (body: string | null) => {
8 if (!body) return '';
9
10 let notesBody = body;
11 if (/(?:(?:\r?\n)|^)Notes: (.+?)(?:(?:\r?\n)|$)/gi.test(notesBody)) {
12 debug('Updating existing default notes template');
13 // Bound the lazy scan to a constant number of characters. The real GitHub
14 // template comment is well under this length, but an unbounded `[\s\S]*?`
15 // under the global flag lets an attacker-controlled body (many copies of
16 // the literal prefix with no closing `-->`) force a re-scan to end-of-string
17 // per occurrence, which is O(n^2) in the body length. Capping the span keeps
18 // each match attempt O(1) so the overall replace stays linear.
19 notesBody = notesBody.replace(
20 /<!-- Please add a one-line description[\s\S]{0,1000}?-->/gi,
21 'none',
22 );
23 } else {
24 debug('Adding Notes: none to PR body');
25 notesBody += '\n\n---\n\nNotes: none';
26 }
27
28 return notesBody;
29};
30
31export const findNoteInPRBody = (body: string | null) => {
32 if (!body) return null;

Callers 2

note.test.tsFile · 0.90
submitFeedbackForPRFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected