MCPcopy Index your code
hub / github.com/CodebuffAI/codebuff / formatUrl

Function formatUrl

cli/src/login/utils.ts:27–55  ·  view source on GitHub ↗
(url: string, maxWidth?: number)

Source from the content-addressed store, hash-verified

25 * Formats a URL for display by wrapping it at logical breakpoints
26 */
27export function formatUrl(url: string, maxWidth?: number): string[] {
28 if (!maxWidth || maxWidth <= 0 || url.length <= maxWidth) {
29 return [url]
30 }
31
32 const lines: string[] = []
33 let remaining = url
34
35 while (remaining.length > 0) {
36 if (remaining.length <= maxWidth) {
37 lines.push(remaining)
38 break
39 }
40
41 // Try to break at a logical point (after /, ?, &, =)
42 let breakPoint = maxWidth
43 for (let i = maxWidth - 1; i > maxWidth - 20 && i > 0; i--) {
44 if (['/', '?', '&', '='].includes(remaining[i])) {
45 breakPoint = i + 1
46 break
47 }
48 }
49
50 lines.push(remaining.substring(0, breakPoint))
51 remaining = remaining.substring(breakPoint)
52 }
53
54 return lines
55}
56
57/**
58 * Determines the color for a character based on its position relative to the sheen

Callers 1

LoginModalFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected