favor (file) name over download (url)
authorAJ ONeal <aj@therootcompany.com>
Sun, 3 May 2020 10:49:28 +0000 (10:49 +0000)
committerAJ ONeal <aj@therootcompany.com>
Sun, 3 May 2020 10:49:28 +0000 (10:49 +0000)
_common/normalize.js

index 6d17ee1ec83ff31ca42620d6fea5bb7c05225922..88e3ce716adc37c75b1c30050b8ca5dca069ad9a 100644 (file)
@@ -38,14 +38,14 @@ function normalize(all) {
       rel.os =
         Object.keys(osMap).find(function (regKey) {
           //console.log('release os:', rel.download, regKey, osMap[regKey]);
-          return osMap[regKey].test(rel.download);
+          return osMap[regKey].test(rel.name || rel.download);
         }) || 'unknown';
     }
 
     if (!rel.arch) {
       archArr.some(function (regKey) {
         //console.log('release arch:', rel.download, regKey, archMap[regKey]);
-        var arch = rel.download.match(archMap[regKey]) && regKey;
+        var arch = (rel.name || rel.download).match(archMap[regKey]) && regKey;
         if (arch) {
           rel.arch = arch;
           return true;
@@ -57,7 +57,7 @@ function normalize(all) {
       // pkg-v1.0.tar.gz => ['gz', 'tar', '0', 'pkg-v1']
       // pkg-v1.0.tar => ['tar', '0' ,'pkg-v1']
       // pkg-v1.0.zip => ['zip', '0', 'pkg-v1']
-      var exts = rel.download.split('.').reverse().slice(0, 2);
+      var exts = (rel.name || rel.download).split('.').reverse().slice(0, 2);
       var ext;
       if ('tar' === exts[1]) {
         rel.ext = exts.reverse().join('.');