File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -230,6 +230,28 @@ describe('GET /api/streak', () => {
230230
231231 expect ( body ) . toContain ( '8s' ) ;
232232 } ) ;
233+
234+ it ( 'accepts the minimum boundary speed "2s"' , async ( ) => {
235+ const response = await GET ( makeRequest ( { user : 'octocat' , speed : '2s' } ) ) ;
236+ const body = await response . text ( ) ;
237+
238+ expect ( body ) . toContain ( '2s' ) ;
239+ } ) ;
240+
241+ it ( 'accepts the maximum boundary speed "20s"' , async ( ) => {
242+ const response = await GET ( makeRequest ( { user : 'octocat' , speed : '20s' } ) ) ;
243+ const body = await response . text ( ) ;
244+
245+ expect ( body ) . toContain ( '20s' ) ;
246+ } ) ;
247+
248+ it ( 'falls back to 8s when speed is a non-integer decimal like "2.0s"' , async ( ) => {
249+ const response = await GET ( makeRequest ( { user : 'octocat' , speed : '2.0s' } ) ) ;
250+ const body = await response . text ( ) ;
251+
252+ expect ( body ) . toContain ( '8s' ) ;
253+ expect ( body ) . not . toContain ( '2.0s' ) ;
254+ } ) ;
233255 } ) ;
234256
235257 describe ( 'scale parameter' , ( ) => {
Original file line number Diff line number Diff line change @@ -119,7 +119,7 @@ export async function GET(request: Request) {
119119 text : isAutoTheme ? selectedTheme . text : text || selectedTheme . text ,
120120 accent : isAutoTheme ? selectedTheme . accent : accent || selectedTheme . accent ,
121121 radius,
122- speed,
122+ speed : speed && / ^ (?: [ 2 - 9 ] | 1 \d | 2 0 ) s $ / . test ( speed ) ? speed : '8s' ,
123123 scale,
124124 font,
125125 autoTheme : isAutoTheme ,
You can’t perform that action at this time.
0 commit comments