@@ -2,20 +2,27 @@ import { describe, expect, test } from "bun:test"
22import { legacyRedirect } from "../src/lib/legacy"
33
44const get = ( path : string , options : { search ?: string ; method ?: string ; locale ?: "de" | null } = { } ) =>
5- legacyRedirect ( { path, search : options . search ?? "" , method : options . method ?? "GET" , locale : options . locale ?? null } )
5+ legacyRedirect ( {
6+ path,
7+ search : options . search ?? "" ,
8+ method : options . method ?? "GET" ,
9+ locale : options . locale ?? null ,
10+ } )
611
712describe ( "legacy redirects" , ( ) => {
813 test ( "desktop downloads go straight to the update API, HEAD included" , ( ) => {
914 for ( const method of [ "GET" , "HEAD" ] ) {
1015 const response = get ( "/download/latest/windows-x64-nsis" , { method } )
1116 expect ( response ?. status ) . toBe ( 302 )
12- expect ( response ?. headers . get ( "Location" ) ) . toBe ( "/update/api/latest/desktop/opencode/opencode-desktop-win-x64.exe" )
17+ expect ( response ?. headers . get ( "Location" ) ) . toBe (
18+ "https://opencode.ai/update/api/latest/desktop/opencode/opencode-desktop-win-x64.exe" ,
19+ )
1320 }
1421 expect ( get ( "/download/stable/linux-x64-deb" ) ?. headers . get ( "Location" ) ) . toBe (
15- "/update/api/latest/desktop/opencode/opencode-desktop-linux-amd64.deb" ,
22+ "https://opencode.ai /update/api/latest/desktop/opencode/opencode-desktop-linux-amd64.deb" ,
1623 )
1724 expect ( get ( "/download/beta/darwin-aarch64-dmg" ) ?. headers . get ( "Location" ) ) . toBe (
18- "/update/api/beta/desktop/opencode/opencode-desktop-mac-arm64.dmg" ,
25+ "https://opencode.ai /update/api/beta/desktop/opencode/opencode-desktop-mac-arm64.dmg" ,
1926 )
2027 expect ( get ( "/download/latest/not-a-platform" ) ?. status ) . toBe ( 404 )
2128 expect ( get ( "/download/latest/toString" ) ?. status ) . toBe ( 404 )
0 commit comments