File tree Expand file tree Collapse file tree 1 file changed +17
-1
lines changed
Expand file tree Collapse file tree 1 file changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -3,12 +3,28 @@ import type { Finding } from './types.d.js';
33import * as url from 'node:url'
44const URL = url . URL ;
55
6+ /** Max length for GitHub issue titles */
7+ const GITHUB_ISSUE_TITLE_MAX_LENGTH = 256 ;
8+
9+ /**
10+ * Truncates text to a maximum length, adding an ellipsis if truncated.
11+ * @param text Original text
12+ * @param maxLength Maximum length of the returned text (including ellipsis)
13+ * @returns Either the original text or a truncated version with an ellipsis
14+ */
15+ function truncateWithEllipsis ( text : string , maxLength : number ) : string {
16+ return text . length > maxLength ? text . slice ( 0 , maxLength - 1 ) + '…' : text ;
17+ }
18+
619export async function openIssue ( octokit : Octokit , repoWithOwner : string , finding : Finding ) {
720 const owner = repoWithOwner . split ( '/' ) [ 0 ] ;
821 const repo = repoWithOwner . split ( '/' ) [ 1 ] ;
922
1023 const labels = [ `${ finding . scannerType } rule: ${ finding . ruleId } ` , `${ finding . scannerType } -scanning-issue` ] ;
11- const title = `Accessibility issue: ${ finding . problemShort [ 0 ] . toUpperCase ( ) + finding . problemShort . slice ( 1 ) } on ${ new URL ( finding . url ) . pathname } ` ;
24+ const title = truncateWithEllipsis (
25+ `Accessibility issue: ${ finding . problemShort [ 0 ] . toUpperCase ( ) + finding . problemShort . slice ( 1 ) } on ${ new URL ( finding . url ) . pathname } ` ,
26+ GITHUB_ISSUE_TITLE_MAX_LENGTH
27+ ) ;
1228 const solutionLong = finding . solutionLong
1329 ?. split ( "\n" )
1430 . map ( ( line ) =>
You can’t perform that action at this time.
0 commit comments