@@ -3,13 +3,13 @@ import { NextRequest, NextResponse } from 'next/server';
33export async function GET ( request : NextRequest ) {
44 const searchParams = request . nextUrl . searchParams ;
55
6- const color = searchParams . get ( 'color' ) || '#2563eb ' ;
6+ const color = searchParams . get ( 'color' ) || '#3b82f6 ' ;
77 const colorGradient = searchParams . get ( 'colorGradient' ) ;
8- const backgroundColor = searchParams . get ( 'backgroundColor' ) || '#f3f4f6 ' ;
9- const progress = parseIntSafe ( searchParams . get ( 'progress' ) , 0 ) ;
10- const height = Math . min ( 500 , Math . max ( 5 , parseIntSafe ( searchParams . get ( 'height' ) , 5 ) ) ) ;
11- const width = Math . min ( 3000 , Math . max ( 10 , parseIntSafe ( searchParams . get ( 'width' ) , 10 ) ) ) ;
12- const borderRadius = Math . min ( 1000 , Math . max ( 0 , parseIntSafe ( searchParams . get ( 'borderRadius' ) , 0 ) ) ) ;
8+ const backgroundColor = searchParams . get ( 'backgroundColor' ) || '#e5e7eb ' ;
9+ const progress = parseIntSafe ( searchParams . get ( 'progress' ) , 65 ) ;
10+ const height = Math . min ( 500 , Math . max ( 5 , parseIntSafe ( searchParams . get ( 'height' ) , 24 ) ) ) ;
11+ const width = Math . min ( 3000 , Math . max ( 10 , parseIntSafe ( searchParams . get ( 'width' ) , 400 ) ) ) ;
12+ const borderRadius = Math . min ( 1000 , Math . max ( 0 , parseIntSafe ( searchParams . get ( 'borderRadius' ) , 12 ) ) ) ;
1313 const striped = searchParams . get ( 'striped' ) === 'true' ;
1414 const animated = searchParams . get ( 'animated' ) === 'true' ;
1515 const animationSpeed = parseFloatSafe ( searchParams . get ( 'animationSpeed' ) , 0 ) ;
@@ -26,10 +26,8 @@ export async function GET(request: NextRequest) {
2626 const shouldAnimate = initialAnimationSpeed > 0 ;
2727 const initialAnimationDuration = ( clampedProgress / 100 ) * ( 1 / initialAnimationSpeed ) ;
2828
29- // Helper function to create gradient definition
3029 const createGradientDef = ( ) => {
3130 if ( colorGradient ) {
32- // Extract colors and positions from gradient string
3331 const matches = colorGradient . match ( / ( # [ A - F a - f 0 - 9 ] { 6 } | # [ A - F a - f 0 - 9 ] { 3 } | r g b a ? \( [ ^ ) ] + \) ) / g) || [ ] ;
3432 if ( matches . length >= 2 ) {
3533 return `
@@ -41,7 +39,6 @@ export async function GET(request: NextRequest) {
4139 ` ;
4240 }
4341 }
44- // Fallback to default gradient using single color
4542 return `
4643 <linearGradient id="progressGradient" x1="0%" y1="0%" x2="100%" y2="0%">
4744 <stop offset="0%" style="stop-color:${ color } ; stop-opacity:1" />
@@ -76,7 +73,6 @@ export async function GET(request: NextRequest) {
7673 </filter>
7774 </defs>
7875
79- <!-- Background -->
8076 <rect
8177 width="${ width } "
8278 height="${ height } "
@@ -85,10 +81,7 @@ export async function GET(request: NextRequest) {
8581 fill="${ backgroundColor } "
8682 filter="url(#shadow)"
8783 />
88-
89- <!-- Progress bar -->
9084 <g clip-path="url(#progressClip)">
91- <!-- Main fill -->
9285 <rect
9386 width="${ width } "
9487 height="${ height } "
@@ -98,7 +91,6 @@ export async function GET(request: NextRequest) {
9891 />
9992
10093 ${ striped ? `
101- <!-- Striped overlay -->
10294 <rect
10395 width="${ progressWidth } "
10496 height="${ height } "
@@ -108,7 +100,6 @@ export async function GET(request: NextRequest) {
108100 ` : '' }
109101 </g>
110102
111- <!-- Rounded corners overlay to ensure proper rounding -->
112103 <rect
113104 width="${ width } "
114105 height="${ height } "
@@ -120,7 +111,6 @@ export async function GET(request: NextRequest) {
120111 opacity="0.5"
121112 />
122113
123- <!-- Animation definitions -->
124114 <style>
125115 @keyframes progress-stripes {
126116 from { background-position: ${ 50 * safeAnimationSpeed } px 0; }
@@ -174,7 +164,6 @@ function adjustColor(color: string, amount: number): string {
174164 return `#${ newR . toString ( 16 ) . padStart ( 2 , '0' ) } ${ newG . toString ( 16 ) . padStart ( 2 , '0' ) } ${ newB . toString ( 16 ) . padStart ( 2 , '0' ) } ` ;
175165}
176166
177- // Helper function to safely parse integers with fallback
178167function parseIntSafe ( value : string | null , defaultValue : number ) : number {
179168 if ( value === null || value === undefined || value === '' ) {
180169 return defaultValue ;
@@ -184,7 +173,6 @@ function parseIntSafe(value: string | null, defaultValue: number): number {
184173 return isNaN ( parsed ) ? defaultValue : parsed ;
185174}
186175
187- // Helper function to safely parse floats with fallback
188176function parseFloatSafe ( value : string | null , defaultValue : number ) : number {
189177 if ( value === null || value === undefined || value === '' ) {
190178 return defaultValue ;
0 commit comments