@@ -459,8 +459,28 @@ <h5 data-i18n="footer.in-touch.header">Keep in Touch</h5>
459459 } ) ;
460460
461461 $ . when ( ajaxRequest , i18nLoaded ) . done ( function ( data ) {
462- var build = data [ 0 ] [ 0 ] ,
463- buildName = build . versionString ;
462+ var allBuilds = data [ 0 ] ,
463+ build = data [ 0 ] [ 0 ] ; // default initialization with latest build
464+
465+ // Find the applicable build for current platform
466+ // If current platform is unsupported (OTHERS), then take the last common release
467+ // If a build entry doesn't have 'platforms' key -> Older format for all supported OS
468+ for ( var buildIndex = 0 ; buildIndex < allBuilds . length ; buildIndex ++ ) {
469+ build = allBuilds [ buildIndex ] ;
470+ if ( ! build . platforms ) { // Older format detected - Applicable to all platforms
471+ break ;
472+ } else {
473+ if ( build . platforms [ OS ] ) { // Current platform is one of the supported platforms
474+ break ;
475+ } else if ( OS == "OTHER" ) { // Unsupported platform detected
476+ if ( Object . keys ( build . platforms ) . length == 4 ) { // Build applicable for all platforms
477+ break ;
478+ }
479+ }
480+ }
481+ }
482+
483+ var buildName = build . versionString ;
464484
465485 // Probe previous entry to see if the update is a dot update,
466486 // in which case combine both the entries.
@@ -477,11 +497,16 @@ <h5 data-i18n="footer.in-touch.header">Keep in Touch</h5>
477497
478498 // update button
479499 if ( OS !== "OTHER" && buildNum ) {
480- var tag = buildName . toLowerCase ( ) . split ( " " ) . join ( "-" ) ,
500+ var url ;
501+ if ( build . platforms && build . platforms [ OS ] ) { // Fetch download url from platform entry
502+ url = build . platforms [ OS ] . downloadURL ;
503+ } else { // Generate the download URI
504+ var tag = buildName . toLowerCase ( ) . split ( " " ) . join ( "-" ) ;
481505 url = "https://github.com/adobe/brackets/releases/" + tag ;
482506
483- if ( ext ) {
484- url = "https://github.com/adobe/brackets/releases/download/" + tag + "/Brackets." + buildName . split ( " " ) . join ( "." ) + ext ;
507+ if ( ext ) {
508+ url = "https://github.com/adobe/brackets/releases/download/" + tag + "/Brackets." + buildName . split ( " " ) . join ( "." ) + ext ;
509+ }
485510 }
486511
487512 $ ( "#download-brackets-version" ) . text ( buildNum ) ;
0 commit comments